Home

function: template


template(string: string, options: Object): function

Creates a compiled template function that can interpolate data properties in "interpolate" delimiters, HTML-escape interpolated data properties in "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data properties may be accessed as free variables in the template. If a setting object is given, it takes precedence over `templateSettings` values. **Note:** In the development build `template` utilizes [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier debugging. For more information on precompiling templates see [lodash's custom builds documentation](https://lodash.com/custom-builds). For more information on Chrome extension sandboxes see [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).

Example(s):

// Use the "interpolate" delimiter to create a compiled template.
let compiled = template('hello <%= user %>!')
compiled({ 'user': 'fred' })
// => 'hello fred!'

// Use the HTML "escape" delimiter to escape data property values.
let compiled = template('<%- value %>')
compiled({ 'value': '