Allow compiled templates loaded via AMD to set and use the private _ variable.

Former-commit-id: 746e6d8275f08dbb628e92c146fffba84df0f8c0
This commit is contained in:
John-David Dalton
2012-12-08 01:26:08 -08:00
parent 32b9de05f2
commit 7313dd74a6

View File

@@ -336,6 +336,7 @@
source.push( source.push(
" if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {", " if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {",
" define(['" + options.moduleId + "'], function(lodash) {", " define(['" + options.moduleId + "'], function(lodash) {",
' _ = lodash;',
' lodash.templates = lodash.extend(lodash.templates || {}, templates);', ' lodash.templates = lodash.extend(lodash.templates || {}, templates);',
' });', ' });',
" } else if (freeExports) {", " } else if (freeExports) {",
@@ -1050,7 +1051,7 @@
var templateSettings = options.reduce(function(result, value) { var templateSettings = options.reduce(function(result, value) {
var match = value.match(/settings=(.+)$/); var match = value.match(/settings=(.+)$/);
return match return match
? Function('assign, result', 'return assign(result, {' + match[1].replace(/^{|}$/g, '') + '})')(_.assign, result) ? _.assign(result, Function('return {' + match[1].replace(/^{|}$/g, '') + '}')())
: result; : result;
}, _.assign(_.clone(_.templateSettings), { }, _.assign(_.clone(_.templateSettings), {
'moduleId': moduleId 'moduleId': moduleId