Merge pull request #7866 from WesleySSmith/underscore-variable

underscore.ts: Add "variable" to TemplateSettings.
This commit is contained in:
Masahiro Wakame 2016-01-29 15:00:50 +09:00
commit 669e1b73f1
2 changed files with 7 additions and 0 deletions

View File

@ -436,6 +436,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> { }