From 25de44a23d9fa7a05073a7ce80af17d10ae005ae Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 19 Sep 2012 00:29:32 -0700 Subject: [PATCH] Cleanup `_.template`. Former-commit-id: dc3fa2d02a9a4a2d4034136d2ce7f03d0b67224a --- build/pre-compile.js | 2 +- lodash.js | 16 ++++++++-------- lodash.min.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build/pre-compile.js b/build/pre-compile.js index e22c1ba64..e564f75a7 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -298,7 +298,7 @@ source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *\{(?:\s*\/\/.*)*\n *var useSourceURL[\s\S]+?catch[^}]+}\n/, ''); // remove debug sourceURL use in `_.template` - source = source.replace(/(?:\s*\/\/.*\n)* *if *\(useSourceURL[^}]+}/, ''); + source = source.replace(/(?:\s*\/\/.*\n)* *var sourceURL[^;]+;|\+ *sourceURL/g, ''); // minify internal properties used by 'compareAscending', `_.merge`, and `_.sortBy` (function() { diff --git a/lodash.js b/lodash.js index 98644ad31..4b6e67594 100644 --- a/lodash.js +++ b/lodash.js @@ -3883,9 +3883,9 @@ // replace delimiters with snippets source += - escapeValue ? "' +\n__e(" + escapeValue + ") +\n'" : - interpolateValue ? "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'" : - evaluateValue ? "';\n" + evaluateValue + ";\n__p += '" : ''; + escapeValue ? "' +\n__e(" + escapeValue + ") +\n'" : + evaluateValue ? "';\n" + evaluateValue + ";\n__p += '" : + interpolateValue ? "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'" : ''; isEvaluating || (isEvaluating = evaluateValue || reComplexDelimiter.test(escapeValue || interpolateValue)); index = offset + match.length; @@ -3927,14 +3927,14 @@ source + 'return __p\n}'; - // add a sourceURL for easier debugging + // use a sourceURL for easier debugging // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl - if (useSourceURL) { - source += '\n//@ sourceURL=/lodash/template/source[' + (templateCounter++) + ']'; - } + var sourceURL = useSourceURL + ? '\n//@ sourceURL=/lodash/template/source[' + (templateCounter++) + ']' + : ''; try { - result = Function('_', 'return ' + source)(lodash); + result = Function('_', 'return ' + source + sourceURL)(lodash); } catch(e) { e.source = source; throw e; diff --git a/lodash.min.js b/lodash.min.js index 874ff8f0c..fbfc2bcce 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -32,7 +32,7 @@ g,s.isNaN=function(e){return tt.call(e)==dt&&e!=+e},s.isNull=function(e){return N,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return G.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=sn,s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s=f?(a=r,s=e.apply(o,i)):u||(u=bt(n,f)),s}},s.times=function(e,t,n){var r=-1,i=Array(e||0);if( n)for(;++rT(t,n[e])&&t.push(n[e]);return t},s.uniq=L,s.uniqueId=function(e){var t=H++;return e?e+t:t},s.values=fn,s.where=Tn,s.without=function(e){var t=[];if(!e)return t ;for(var n=-1,r=e.length,i=a(arguments,1,20);++n