The lodash method templateSettings exported as a module for template delimiter configuration.
npx @tessl/cli install tessl/npm-lodash--templatesettings@3.1.0Lodash Template Settings provides the lodash _.templateSettings configuration object as a standalone Node.js module. It enables template delimiter customization for lodash's template engine without requiring the full lodash library. This package exports the default configuration used by lodash's _.template() function, including regular expressions for different template delimiter types and default import variables.
npm install lodash.templatesettingsvar templateSettings = require('lodash.templatesettings');This package provides the default template settings configuration for lodash's template system. It contains:
The settings object is designed to be passed to lodash's _.template() function or used to understand the default template parsing behavior.
var templateSettings = require('lodash.templatesettings');
// Access template delimiter patterns
console.log(templateSettings.escape); // /<%-([\s\S]+?)%>/g
console.log(templateSettings.evaluate); // /<%([\s\S]+?)%>/g
console.log(templateSettings.interpolate); // /<%=([\s\S]+?)%>/g
// Use with lodash template function (if available)
// var template = _.template('Hello <%= name %>!', templateSettings);
// Example with custom delimiters (hypothetical usage)
// var customSettings = Object.assign({}, templateSettings);
// var compiled = _.template('Hello {{= name }}!', customSettings);The main export containing all template delimiter configuration.
/**
* Template settings configuration object
* @type {Object}
*/
var templateSettings = {
escape: RegExp,
evaluate: RegExp,
interpolate: RegExp,
variable: string,
imports: Object
};Regular expression for HTML-escaped template delimiters (<%- %>).
/**
* Used to detect data property values to be HTML-escaped
* @type {RegExp}
* @value /<%-([\s\S]+?)%>/g
*/
templateSettings.escapeRegular expression for code evaluation template delimiters (<% %>).
/**
* Used to detect code to be evaluated
* @type {RegExp}
* @value /<%([\s\S]+?)%>/g
*/
templateSettings.evaluateRegular expression for interpolation template delimiters (<%= %>).
/**
* Used to detect data property values to inject
* @type {RegExp}
* @value /<%=([\s\S]+?)%>/g
*/
templateSettings.interpolateString used to reference the data object in template text.
/**
* Used to reference the data object in the template text
* @type {string}
* @value ''
*/
templateSettings.variableObject containing variables imported into compiled templates.
/**
* Used to import variables into the compiled template
* @type {Object}
*/
templateSettings.importsThe lodash utilities object available in template context, containing the escape function.
/**
* Object containing lodash utilities available in templates
* @type {Object}
*/
templateSettings.imports._
/**
* HTML escape function from lodash.escape module
* @type {Function}
* @param {*} value - Value to HTML-escape
* @returns {string} HTML-escaped string
*/
templateSettings.imports._.escape/**
* Template settings configuration object structure
*/
interface TemplateSettings {
/** RegExp for HTML-escaped delimiters (<%- %>) */
escape: RegExp;
/** RegExp for evaluation delimiters (<% %>) */
evaluate: RegExp;
/** RegExp for interpolation delimiters (<%= %>) */
interpolate: RegExp;
/** Variable name for template data object reference */
variable: string;
/** Object containing imported template variables */
imports: {
/** Lodash utilities available in templates */
_: {
/** HTML escape function */
escape: (value: any) => string;
};
};
}