Uses Craft.js
(API docs).
var myTemplate = Template.create({
template : "<p>#{foo}<p><i>#{bar.baz}</i>",
pattern : /#\{([a-zA-Z0-9-_.]*)\}/g,
defaults : {
bar : {
baz : "foo"
}
}
})
template
: String to evaluatepattern
(optional) : custom RegExp (default handles{{variable}}
)defaults
: Default values following the expected structure in theTemplate#evaluate
function.
myTemplate.evaluate(data) // -> String