Provides a generic API for using template engines such as Handlebars and
Y.Template.Micro.
Using with Y.Template.Micro (the default template engine):
YUI().use('template', function (Y) {
var micro = new Y.Template(),
html = micro.render('<%= data.message %>', {message: 'hello!'});
// ...
});
Using with Handlebars:
YUI().use('template-base', 'handlebars', function (Y) {
var handlebars = new Y.Template(Y.Handlebars),
html = handlebars.render('{{message}}', {message: 'hello!'});
// ...
});
Template[engine=Y.Template.Micro]
[defaults]
[engine=Y.Template.Micro]
Mixed
optional
Template engine to use, such as
Y.Template.Micro or Y.Handlebars. Defaults to Y.Template.Micro if not
specified.
[defaults]
Object
optional
Default options to use when instance methods are invoked.
compiletext
[options]
Compiles a template with the current template engine and returns a compiled template function.
precompiletext
[options]
Precompiles a template with the current template engine and returns a string containing JavaScript source code for the precompiled template.
rendertext
data
[options]
Compiles and renders a template with the current template engine in a single step, and returns the rendered result.
reviveprecompiled
[options]
Revives a precompiled template function into an executable template function using the current template engine. The precompiled code must already have been evaluated; this method won't evaluate it for you.