This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Data Types
Lukas Jans edited this page Feb 21, 2019
·
1 revision
Instead of passing an object with properties to the renderer, you can also use other types of data.
If you pass a scalar directly to the renderer, it can only be referenced using the local context:
Elements.render('A {{.}} C', 'B');
A B C
When an array is passed directly to the renderer, the whole template will be repeated and rendered for each item in the array. Like usual, the items can be scalars or other types of data.
Elements.render('<a href="#{{.}}">{{.}}</a>', ['top', 'bottom']);
<a href="#top">top</a>
<a href="#bottom">bottom</a>
Class instances behave like objects, so they can also be used for rendering:
class Test {
get value() { return 'world'; }
alter(text) { return text.toUpperCase(); }
}
Elements.render('{{#alter}}Hello{{/alter}} {{value}}!', new Test());
HELLO world!