or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-lodash--templatesettings

The lodash method templateSettings exported as a module for template delimiter configuration.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash.templatesettings@3.1.x

To install, run

npx @tessl/cli install tessl/npm-lodash--templatesettings@3.1.0

index.mddocs/

Lodash Template Settings

Lodash 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.

Package Information

  • Package Name: lodash.templatesettings
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash.templatesettings

Core Imports

var templateSettings = require('lodash.templatesettings');

Architecture

This package provides the default template settings configuration for lodash's template system. It contains:

  • Delimiter Patterns: Regular expressions that define template syntax patterns
  • Variable Reference: Configuration for template data object access
  • Import Context: Functions and utilities available within templates

The settings object is designed to be passed to lodash's _.template() function or used to understand the default template parsing behavior.

Basic Usage

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);

Capabilities

Template Settings Object

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
};

Escape Delimiter

Regular expression for HTML-escaped template delimiters (<%- %>).

/**
 * Used to detect data property values to be HTML-escaped
 * @type {RegExp}
 * @value /<%-([\s\S]+?)%>/g
 */
templateSettings.escape

Evaluate Delimiter

Regular expression for code evaluation template delimiters (<% %>).

/**
 * Used to detect code to be evaluated
 * @type {RegExp}
 * @value /<%([\s\S]+?)%>/g
 */
templateSettings.evaluate

Interpolate Delimiter

Regular expression for interpolation template delimiters (<%= %>).

/**
 * Used to detect data property values to inject
 * @type {RegExp}
 * @value /<%=([\s\S]+?)%>/g
 */
templateSettings.interpolate

Variable Reference

String used to reference the data object in template text.

/**
 * Used to reference the data object in the template text
 * @type {string}
 * @value ''
 */
templateSettings.variable

Template Imports

Object containing variables imported into compiled templates.

/**
 * Used to import variables into the compiled template
 * @type {Object}
 */
templateSettings.imports

Escape Function Import

The 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

Types

/**
 * 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;
    };
  };
}