Ensure that passing settings=... does not clobber the default moduleId.

Precompiling a template with `settings` previously generated a snippet
resembling `define(["undefined"], function(lodash) { ... })` if the `settings`
object did not contain a `moduleId` property. You can now pass `settings` and
`moduleId` options simultaneously; the builder will always use the `moduleId`
property in `settings` if it is provided, and default to `moduleId` otherwise.


Former-commit-id: 711b4f167dc08ce3d42029e9001ebdb2d8d60a56
This commit is contained in:
Kit Cambridge
2012-12-07 19:41:11 -08:00
parent cdeb50132d
commit c79bed22f8
2 changed files with 26 additions and 15 deletions

View File

@@ -1050,7 +1050,7 @@
var templateSettings = options.reduce(function(result, value) {
var match = value.match(/settings=(.+)$/);
return match
? Function('return {' + match[1].replace(/^{|}$/g, '') + '}')()
? Function('assign, result', 'return assign(result, {' + match[1].replace(/^{|}$/g, '') + '})')(_.assign, result)
: result;
}, _.assign(_.clone(_.templateSettings), {
'moduleId': moduleId