-
Notifications
You must be signed in to change notification settings - Fork 18
Templating
...
...
In order to include partial based on data the handlebars helper dynamicPartial can be used. please follow the examples on this page: Handlebars Page
data is passed either by the global data object, by providing an object or by passing it directly as options in the include tag.
Object: {{> "modules/mymodule/mymodule" modules.mymodule}}
Params: {{> "modules/mymodule/mymodule" title="Today is Thursday" state="cloudy"}}
To use precompiled Templates (bundled with the js-package) you need to do these things:
- create a handlerbars file with this pattern
_modulename_templatename.js.hbs
inside the module-folder. - write your template using handlebars syntax. example: https://github.com/unic/estatico/blob/develop/source/demo/modules/slideshow/_slideshow_slide.js.hbs
add references to your module.
var templates = {
foo: require('./_module_foo.js.hbs')
};
requireing a handlebars template this way automatically makes it usable as handlebars-template inside your js-module.
parse template with data
var data = {
title: 'foo',
text: 'bar'
}
var templateOutput = templates.foo(data);
an example can be seen in the slideshow-demo-module: slideshow.js#L6 and slideshow.js#L104