or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.md
tile.json

index.mddocs/

0

# Lodash Template Settings

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: lodash.templatesettings

7

- **Package Type**: npm

8

- **Language**: JavaScript

9

- **Installation**: `npm install lodash.templatesettings`

10

11

## Core Imports

12

13

```javascript

14

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

15

```

16

17

## Architecture

18

19

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

20

21

- **Delimiter Patterns**: Regular expressions that define template syntax patterns

22

- **Variable Reference**: Configuration for template data object access

23

- **Import Context**: Functions and utilities available within templates

24

25

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

26

27

## Basic Usage

28

29

```javascript

30

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

31

32

// Access template delimiter patterns

33

console.log(templateSettings.escape); // /<%-([\s\S]+?)%>/g

34

console.log(templateSettings.evaluate); // /<%([\s\S]+?)%>/g

35

console.log(templateSettings.interpolate); // /<%=([\s\S]+?)%>/g

36

37

// Use with lodash template function (if available)

38

// var template = _.template('Hello <%= name %>!', templateSettings);

39

40

// Example with custom delimiters (hypothetical usage)

41

// var customSettings = Object.assign({}, templateSettings);

42

// var compiled = _.template('Hello {{= name }}!', customSettings);

43

```

44

45

## Capabilities

46

47

### Template Settings Object

48

49

The main export containing all template delimiter configuration.

50

51

```javascript { .api }

52

/**

53

* Template settings configuration object

54

* @type {Object}

55

*/

56

var templateSettings = {

57

escape: RegExp,

58

evaluate: RegExp,

59

interpolate: RegExp,

60

variable: string,

61

imports: Object

62

};

63

```

64

65

### Escape Delimiter

66

67

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

68

69

```javascript { .api }

70

/**

71

* Used to detect data property values to be HTML-escaped

72

* @type {RegExp}

73

* @value /<%-([\s\S]+?)%>/g

74

*/

75

templateSettings.escape

76

```

77

78

### Evaluate Delimiter

79

80

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

81

82

```javascript { .api }

83

/**

84

* Used to detect code to be evaluated

85

* @type {RegExp}

86

* @value /<%([\s\S]+?)%>/g

87

*/

88

templateSettings.evaluate

89

```

90

91

### Interpolate Delimiter

92

93

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

94

95

```javascript { .api }

96

/**

97

* Used to detect data property values to inject

98

* @type {RegExp}

99

* @value /<%=([\s\S]+?)%>/g

100

*/

101

templateSettings.interpolate

102

```

103

104

### Variable Reference

105

106

String used to reference the data object in template text.

107

108

```javascript { .api }

109

/**

110

* Used to reference the data object in the template text

111

* @type {string}

112

* @value ''

113

*/

114

templateSettings.variable

115

```

116

117

### Template Imports

118

119

Object containing variables imported into compiled templates.

120

121

```javascript { .api }

122

/**

123

* Used to import variables into the compiled template

124

* @type {Object}

125

*/

126

templateSettings.imports

127

```

128

129

### Escape Function Import

130

131

The lodash utilities object available in template context, containing the escape function.

132

133

```javascript { .api }

134

/**

135

* Object containing lodash utilities available in templates

136

* @type {Object}

137

*/

138

templateSettings.imports._

139

140

/**

141

* HTML escape function from lodash.escape module

142

* @type {Function}

143

* @param {*} value - Value to HTML-escape

144

* @returns {string} HTML-escaped string

145

*/

146

templateSettings.imports._.escape

147

```

148

149

## Types

150

151

```javascript { .api }

152

/**

153

* Template settings configuration object structure

154

*/

155

interface TemplateSettings {

156

/** RegExp for HTML-escaped delimiters (<%- %>) */

157

escape: RegExp;

158

/** RegExp for evaluation delimiters (<% %>) */

159

evaluate: RegExp;

160

/** RegExp for interpolation delimiters (<%= %>) */

161

interpolate: RegExp;

162

/** Variable name for template data object reference */

163

variable: string;

164

/** Object containing imported template variables */

165

imports: {

166

/** Lodash utilities available in templates */

167

_: {

168

/** HTML escape function */

169

escape: (value: any) => string;

170

};

171

};

172

}

173

```