Skip to content

Commit 252573a

Browse files
committed
docs: locals data from script tag
1 parent e730454 commit 252573a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

readme.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ You have full control over the delimiters used for injecting locals, as well as
4242
| **delimiters** | `['{{', '}}']` | Array containing beginning and ending delimiters for escaped locals |
4343
| **unescapeDelimiters** | `['{{{', '}}}']` | Array containing beginning and ending delimiters for unescaped locals |
4444
| **locals** | `{}` | Object containing any local variables you want to be available inside your expressions |
45+
| **localsAttr** | `locals` | Attribute name for the tag `script` which contains ***[locals](#locals)***|
4546
| **conditionalTags** | `['if', 'elseif', 'else']` | Array containing names for tags used for `if/else if/else` statements |
4647
| **switchTags** | `['switch', 'case', 'default']` | Array containing names for tags used for `switch/case/default` statements |
4748
| **loopTags** | `['each']` | Array containing names for `for` loops |
@@ -71,6 +72,28 @@ locals: { className: 'intro', name: 'Marlo', 'status': 'checked' }
7172
</div>
7273
```
7374

75+
You can also use the script tag with the attribute `locals` or you custome attribute containing data to interpolate in the template.
76+
77+
```html
78+
<script locals>
79+
module.exports = {
80+
name: 'Scrum'
81+
}
82+
</script>
83+
84+
<div>My name: {{name}}</div>
85+
```
86+
87+
```html
88+
<script locals>
89+
module.exports = {
90+
name: 'Scrum'
91+
}
92+
</script>
93+
94+
<div>My name: Scrum</div>
95+
```
96+
7497
### Unescaped Locals
7598

7699
By default, special characters will be escaped so that they show up as text, rather than html code. For example, if you had a local containing valid html as such:

0 commit comments

Comments
 (0)