From 7313dd74a6613bcfb24e3063bbb050b6586727f7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 8 Dec 2012 01:26:08 -0800 Subject: [PATCH] Allow compiled templates loaded via AMD to set and use the private `_` variable. Former-commit-id: 746e6d8275f08dbb628e92c146fffba84df0f8c0 --- build.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.js b/build.js index 940379029..c47c5cae1 100755 --- a/build.js +++ b/build.js @@ -336,6 +336,7 @@ source.push( " if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {", " define(['" + options.moduleId + "'], function(lodash) {", + ' _ = lodash;', ' lodash.templates = lodash.extend(lodash.templates || {}, templates);', ' });', " } else if (freeExports) {", @@ -1050,7 +1051,7 @@ var templateSettings = options.reduce(function(result, value) { var match = value.match(/settings=(.+)$/); return match - ? Function('assign, result', 'return assign(result, {' + match[1].replace(/^{|}$/g, '') + '})')(_.assign, result) + ? _.assign(result, Function('return {' + match[1].replace(/^{|}$/g, '') + '}')()) : result; }, _.assign(_.clone(_.templateSettings), { 'moduleId': moduleId