handlebars-site icon indicating copy to clipboard operation
handlebars-site copied to clipboard

Usage example for --simple precompilation option

Open giles-v opened this issue 8 years ago • 0 comments

Using the --simple precompilation flag outputs an object with a main function like this:

{"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    [snip]
},"usePartial":true,"useData":true}

It's not clear how templates precompiled in this manner should be loaded or rendered. The docs say:

If using the simple mode the precompiler will generate a single javascript method. To execute this method it must be passed to the Handlebars.template method and the resulting object may be used as normal.

But this file does not contain a single method. Should I be passing templateObj.main to the Handlebars.template method and ignoring the other object properties? An example would really help here.

giles-v avatar Dec 06 '16 16:12 giles-v