mikel 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,6 +219,23 @@ The `ne` helper renders the block only if the two values provided as argument ar
|
|
|
219
219
|
console.log(m(`{{#ne name "bob"}}Not bob{{/ne}}`, {name: "John"})); // --> 'Not bob'
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
+
#### with
|
|
223
|
+
|
|
224
|
+
> Added in `v0.10.0`.
|
|
225
|
+
|
|
226
|
+
The `with` helper allows to change the data context of the block.
|
|
227
|
+
|
|
228
|
+
```javascript
|
|
229
|
+
const data = {
|
|
230
|
+
autor: {
|
|
231
|
+
name: "Bob",
|
|
232
|
+
email: "bob@email.com",
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
console.log(m("{{#with autor}}{{name}} <{{email}}>{{/with}}", data)); // --> 'Bob <bob@email.com>'
|
|
237
|
+
```
|
|
238
|
+
|
|
222
239
|
### Custom Helpers
|
|
223
240
|
|
|
224
241
|
> Added in `v0.5.0`.
|
package/index.js
CHANGED
|
@@ -91,6 +91,7 @@ const defaultHelpers = {
|
|
|
91
91
|
"unless": (value, opt) => !!!value ? opt.fn(opt.context) : "",
|
|
92
92
|
"eq": (a, b, opt) => a === b ? opt.fn(opt.context) : "",
|
|
93
93
|
"ne": (a, b, opt) => a !== b ? opt.fn(opt.context) : "",
|
|
94
|
+
"with": (value, opt) => opt.fn(value),
|
|
94
95
|
};
|
|
95
96
|
|
|
96
97
|
const compile = (tokens, output, context, partials, helpers, vars, fn = {}, index = 0, section = "") => {
|