mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Further optimize _.template by controlling how the with-statement is inserted.
Former-commit-id: a62331e771302f9390d5aca04f878b839fe11b69
This commit is contained in:
@@ -224,12 +224,17 @@
|
||||
});
|
||||
|
||||
// remove whitespace from `_.template` related regexpes
|
||||
source = source.replace(/(?:reEmptyString\w+|reInsertVariable) *=.+/g, function(match) {
|
||||
return match.replace(/ /g, '');
|
||||
source = source.replace(/(?:reDelimiterCode\w+|reEmptyString\w+|reInsertVariable) *=.+/g, function(match) {
|
||||
return match.replace(/ |\\n/g, '');
|
||||
});
|
||||
|
||||
// remove newline from double-quoted string in `_.template`
|
||||
source = source.replace('"\';\\n"', '"\';"');
|
||||
// remove newline from double-quoted strings in `_.template`
|
||||
source = source
|
||||
.replace('"\';\\n__with ("', '"\';__with("')
|
||||
.replace('"\\n}__\\n__p += \'"', '"}____p+=\'"')
|
||||
.replace('"__p = \'"', '"__p=\'"')
|
||||
.replace('"\';\\n"', '"\';"')
|
||||
.replace("') {\\n'", "'){'")
|
||||
|
||||
// remove `useSourceURL` variable
|
||||
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *\{(?:\s*\/\/.*\n)* *var useSourceURL[\s\S]+?catch[^}]+}\n/, '');
|
||||
|
||||
Reference in New Issue
Block a user