Add "variable" to TemplateSettings.

This commit is contained in:
Wesley Smith
2016-01-28 12:18:30 -08:00
parent 86dbea8fc3
commit 130dd500af
2 changed files with 7 additions and 0 deletions

View File

@@ -432,6 +432,7 @@ var template2 = _.template("Hello {{ name }}!");
template2({ name: "Mustache" });
_.template("Using 'with': <%= data.answer %>", oldTemplateSettings)({ variable: 'data' });
_.template("Using 'with': <%= data.answer %>", { variable: 'data' })({ answer: 'no' });
_(['test', 'test']).pick(['test2', 'test2']);

View File

@@ -39,6 +39,12 @@ declare module _ {
* Default value is '/<%-([\s\S]+?)%>/g'.
**/
escape?: RegExp;
/**
* By default, 'template()' places the values from your data in the local scope via the 'with' statement.
* However, you can specify a single variable name with this setting.
**/
variable?: string;
}
interface Collection<T> { }