Skip to content

Methods

Chris Talman edited this page Aug 3, 2015 · 5 revisions

Several methods allow you to interface with Emboss.

Emboss.compile()

Emboss.compile() compiles a template. See the Precompilation page for more details.

var compiledTemplate = Emboss.compile(templateSource);

Emboss.render()

Emboss.render() renders a template. To 'render' a template is to generate its output. In other words, this is the outputted HTML.

Its first argument can either be a compiled template or a template source. Compiled templates can be attained through Emboss.compile() or Emboss.getPrecompiledTemplate().

It expects its second argument, if defined, to be an object containing data for the template. This argument is optional.

document.body.innerHTML = Emboss.render(template, {message: 'Hello World!'});

Emboss.bulkPrecompile()

Emboss.bulkPrecompile precompiles all templates in a document in bulk. See the Precompilation page for more details.

Emboss.storePrecompiledTemplate()

Emboss.storePrecompiledTemplate() stores a precompiled template. It is used by the precompiled templates script produced by Emboss.bulkPrecompile() to store precompiled templates in a neat and accessible manner. Users should not need to make use of this method themselves.

Emboss.getPrecompiledTemplate()

Emboss.getPrecompiledTemplate() retrieves a precompiled template. See the Precompilation page for more details.

var precompiledTemplate = Emboss.getPrecompiledTemplate('templateID');
Clone this wiki locally