From 130dd500af985076aa1cd0274bbef30fa9e47ff7 Mon Sep 17 00:00:00 2001 From: Wesley Smith Date: Thu, 28 Jan 2016 12:18:30 -0800 Subject: [PATCH] Add "variable" to TemplateSettings. --- underscore/underscore-tests.ts | 1 + underscore/underscore.d.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 74cef85ec7..262c987ea8 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -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']); diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 66b2e8f3ec..2f6ab1e757 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -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 { }