Remove legacy options param signature from _.template.

This commit is contained in:
John-David Dalton
2016-01-03 16:53:19 -06:00
parent 9ef191db33
commit f39fdc42f6
2 changed files with 5 additions and 14 deletions

View File

@@ -12287,7 +12287,7 @@
* @param {RegExp} [options.interpolate] The "interpolate" delimiter. * @param {RegExp} [options.interpolate] The "interpolate" delimiter.
* @param {string} [options.sourceURL] The sourceURL of the template's compiled source. * @param {string} [options.sourceURL] The sourceURL of the template's compiled source.
* @param {string} [options.variable] The data object variable name. * @param {string} [options.variable] The data object variable name.
* @param- {Object} [otherOptions] Enables the legacy `options` param signature. * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
* @returns {Function} Returns the compiled template function. * @returns {Function} Returns the compiled template function.
* @example * @example
* *
@@ -12355,16 +12355,16 @@
* };\ * };\
* '); * ');
*/ */
function template(string, options, otherOptions) { function template(string, options, guard) {
// Based on John Resig's `tmpl` implementation (http://ejohn.org/blog/javascript-micro-templating/) // Based on John Resig's `tmpl` implementation (http://ejohn.org/blog/javascript-micro-templating/)
// and Laura Doktorova's doT.js (https://github.com/olado/doT). // and Laura Doktorova's doT.js (https://github.com/olado/doT).
var settings = lodash.templateSettings; var settings = lodash.templateSettings;
if (otherOptions && isIterateeCall(string, options, otherOptions)) { if (guard && isIterateeCall(string, options, guard)) {
options = otherOptions = undefined; options = undefined;
} }
string = toString(string); string = toString(string);
options = assignInWith({}, otherOptions || options, settings, assignInDefaults); options = assignInWith({}, options, settings, assignInDefaults);
var imports = assignInWith({}, options.imports, settings.imports, assignInDefaults), var imports = assignInWith({}, options.imports, settings.imports, assignInDefaults),
importsKeys = keys(imports), importsKeys = keys(imports),

View File

@@ -19208,15 +19208,6 @@
} }
}); });
QUnit.test('should support the legacy `options` argument signature', function(assert) {
assert.expect(1);
var compiled = _.template('<%= data.a %>', null, { 'variable': 'data' }),
data = { 'a': 1 };
assert.strictEqual(compiled(data), '1');
});
QUnit.test('should support custom delimiters', function(assert) { QUnit.test('should support custom delimiters', function(assert) {
assert.expect(2); assert.expect(2);