Compiles a string into a template function. TypeDoc doc page


Sqrl.compile (str, options)
// returns a function that can be called with (data, options, [cb])
// note: options must be a valid config object

See the page on options


var myTemplate = "Hi, my name is {{}}";
var compiled = Sqrl.compile(myTemplate);
// Returns a function:
// function anonymous(it,c,cb ) { var tR='';tR+='Hi, my name is ';tR+=c.l('F','e')(;if(cb){cb(null,tR)} return tR }
compiled({ name: "Johnny Appleseed" }, Sqrl.defaultConfig);
//Returns "Hi, my name is Johnny Appleseed"
Many template engines offer you the option to Compile (which just renders your template) or Precompile (which turns your template into a function ahead of time). Squirrelly precompiles automatically, but is still faster than other engines.