Compiles a string into a template function. TypeDoc doc page


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

See the page on config


var myTemplate = "Hi, my name is <%= %>"
var compiled = Eta.compile(myTemplate)
// Returns a function:
// function anonymous(it,c,cb ) { var tR='';tR+='Hi, my name is ';tR+=E.e(;if(cb){cb(null,tR)} return tR }
compiled({ name: "Johnny Appleseed" }, Eta.config)
//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). Eta precompiles automatically, but is still faster than other engines.