A RegExp that detects interpolate tags — spots where a JavaScript expression’s value is inserted into the template output. Default matches <%= … %>. Used by _.template().
Set the property globally, or override it per call with options passed to _.template().
Syntax
Use _.templateSettings.interpolate. Start with this line.
Lodash
_.templateSettings.interpolate
Call
What it does
_.templateSettings.interpolate
Primary setting.
_.templateSettings.interpolate = /.../g
Assign a custom RegExp or value before compiling.
Prefer the full Lodash build when using _.template() and _.templateSettings.
Interpolate escapes HTML; the escape delimiter prints raw.
Lodash
var data = { html: '<b>x</b>' };
_.template('safe=<%= html %>')(data);
// → 'safe=<b>x</b>'
_.template('raw=<%- html %>')(data);
// → 'raw=<b>x</b>'
Pattern. Common when you want brace values + ERB logic.
Compatibility
Browser & Runtime Support
_.templateSettings.interpolate is a Lodash templateSettings property used by _.template. It runs anywhere Lodash 4.x runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
Available with [email protected] full builds that include _.template. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
.interpolateLodash 4.x
Bottom line: Safe for production with trusted templates only. Prefer options.interpolate for one-off delimiter changes. Note: _.template is planned for removal in Lodash v5.
Frequently Asked Questions
It is a RegExp that detects interpolate tags — places where a JavaScript expression’s value is inserted into the output. The default matches ERB-style percent-equals tags.
A RegExp. Lodash reads the pattern at compile time. Do not assign a callback.
Set _.templateSettings.interpolate = /{{([\s\S]+?)}}/g (or pass the same RegExp as options.interpolate), then write hello {{ user }}! and render with { user: 'pebbles' }.
interpolate controls percent-equals tags (HTML-escaped insertion). escape controls percent-dash tags (raw / unescaped insertion). Different RegExps, different output safety.
At compile time. Change the RegExp before _.template() runs, or pass options.interpolate. Already-compiled functions keep their original delimiters.
No. Compiling untrusted templates can execute code. Lodash plans to remove _.template in v5.