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
+46-25Lines changed: 46 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,19 +101,21 @@ import { template } from 'micro-template';
101
101
template.get=function (id) { returnrequire('fs').readFileSync('tmpl/'+ id +'.tmpl', 'utf-8') };
102
102
```
103
103
104
-
DEFINE DATA VARIABLE EXPLICITLY
105
-
-------------------------------
104
+
DEFINE DATA VARIABLE SCOPE
105
+
----------------------------
106
106
107
-
By default, micro-template uses `with` syntax to expand data variables. This behavior is almost convenience, but if you want to expressly fast template function, you can do without `with` by specify `template.varible`.
107
+
micro-template now always expands data variables as local variables in the template function. The template API only supports two arguments: the template source/id and the data object. All keys of the data object are available as local variables in the template code.
`template.variable` is used to data variable name in template code. And `with` syntax is not used any more. So you can't refer to variable without `tmpl.` prefix in this case.
116
+
You can access all properties of the data object directly as variables inside the template.
117
+
118
+
**Note:** The previous API that allowed calling `template(tmpl)` to return a function is removed. Always use the two-argument form: `template(tmpl, data)`.
117
119
118
120
EXTENDED FEATURES
119
121
-----------------
@@ -170,25 +172,44 @@ node:
170
172
* node misc/benchmark.js
171
173
172
174
```log
173
-
A larger number (count) means faster. A smaller number (msec) means faster.
174
-
Linux (linux) x64 6.6.87.1-microsoft-standard-WSL2 13th Gen Intel(R) Core(TM) i7-13700K 24 cpus
0 commit comments