You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+25-7Lines changed: 25 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -37,17 +37,18 @@ You have full control over the delimiters used for injecting locals, as well as
37
37
38
38
|Option|Default|Description|
39
39
|:----:|:-----:|:----------|
40
-
|**delimiters**|`['{{', '}}']`| Array containing beginning and ending delimiters for escaped locals |
41
-
|**unescapeDelimiters**|`['{{{', '}}}']`| Array containing beginning and ending delimiters for unescaped locals |
42
-
|**locals**|`{}`| Object containing any local variables you want to be available inside your expressions |
40
+
|**delimiters**|`['{{', '}}']`| Array containing beginning and ending delimiters for escaped locals os [expressions](#expressions)|
41
+
|[**unescapeDelimiters**](#unescaped-locals)|`['{{{', '}}}']`| Array containing beginning and ending delimiters for unescaped locals |
42
+
|[**locals**](#locals)|`{}`| Object containing any local variables you want to be available inside your expressions |
43
43
|**localsAttr**|`locals`| Attribute name for the tag `script` which contains ***[locals](#locals)***|
44
44
|**removeScriptLocals**|`false`| Will remove tag `script` which contains ***[locals](#locals)***|
45
-
|**conditionalTags**|`['if', 'elseif', 'else']`| Array containing names for tags used for `if/else if/else` statements |
46
-
|**switchTags**|`['switch', 'case', 'default']`| Array containing names for tags used for `switch/case/default` statements |
45
+
|[**conditionalTags**](#conditionals)|`['if', 'elseif', 'else']`| Array containing names for tags used for [*`if/else` statements*](#conditionals)|
46
+
|[**switchTags**](#switchtags)|`['switch', 'case', 'default']`| Array containing names for tags used for [*`switch/case/default` statements*](#switch-statement)|
47
47
|**loopTags**|`['each']`| Array containing names for `for` loops |
48
48
|**scopeTags**|`['scope']`| Array containing names for scopes |
49
-
|**ignoredTag**|`'raw'`| String containing name of tag inside which parsing is disabled |
50
-
|**strictMode**|`true`| Boolean value set to `false` will not throw an exception |
49
+
|[**ignoredTag**](#ignored-tag)|`'raw'`| String containing name of tag inside which parsing is disabled |
50
+
|**strictMode**|`true`| Boolean value set to `false` will not throw an exception if a value in locals not found or expression could not be evaluated|
51
+
|[**missingLocal**](#missing-locals)|`undefined`| string defining the replacement value in case value not found in locals. May contain `{expression}` placeholder|
What to produce in case of referencing a value not in `locals` can be configured by the `missingLocal` and `strictMode` options.
130
+
131
+
When `strictMode` is true (default) and leaving the `missingLocal` option `undefined`, then "'foo' is not defined" exception is thrown.
132
+
133
+
Setting `strictMode` false and leaving the `missingLocal` option `undefined` results the string `undefined` in the output
134
+
135
+
Setting the option `missingLocal` to a string will produce that string in the output regardless the value of option `strictMode`. `missingLocal` can contain the placeholder `{local}` which will be replaced with the name of the missing local in the output. This solution allows to:
136
+
1. Silently ignore missing locals by setting `missingLocal` to `""`
137
+
2. Include the name of the missing local in the output to help detect the which value is missing in `locals` like "#Missing value: {local}"
138
+
139
+
|`missingLocal`|`strictMode`|output|
140
+
|:----:|:-----:|:----------|
141
+
|`undefined` (default) |`true` (default) | Error is thrown |
142
+
|`undefined` (default) |`false`| 'undefined' |
143
+
| `''` | `false`/`true` | `''` (not output)
144
+
| `{local}` | `false`/`true` | original reference like `{{foo}}`
0 commit comments