Render

Syntax

Sqrl.Render(template, options)
//If template is a function, returns the result of template(options, Sqrl)
//If template is a string, it will Compile the string
//and then return compiled(options, Sqrl)

Rendering a function is usually better for performance, since Squirrelly doesn't have to re-compile the template each time it Renders.

Caching is available. Set options.$cache to true, and set options.$name to some string value so Squirrelly can cache the resulting function.

Examples

Rendering a string

var myTemplate = `
My favorite template engine is {{fav}}
`
Sqrl.Render(myTemplate, {
fav: "Squirrelly!"
})
//Returns "My favorite template engine is Squirrelly!"

Rendering a function

var myTemplate = `
My favorite template engine is {{fav}}
`
var compiledTemplate = Sqrl.Compile(myTemplate)
Sqrl.Render(compiledTemplate, {
fav: "Squirrelly!"
})
//Returns "My favorite template engine is Squirrelly!"

‚Äč