Skip to content

How to use Precompiling templates? #2064

Closed Answered by jackusay
jackusay asked this question in Q&A
Discussion options

You must be logged in to vote

chatgpt

You:
in nodejs

main.js:

let template = "Handlebars <b>{{doesWhat}}</b> precompiled!";
let Handlebars = require("handlebars");
let compiled = Handlebars.precompile(template);

const fs = require('fs'); 
fs.writeFileSync("b", compiled); 

works ok.
I get this in b:

{"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
    var helper, lookupProperty = container.lookupProperty || function(parent, propertyName) {
        if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
          return parent[propertyName];
        }
        return undefined
    };

  return "Handlebars <b>"
    + container.escapeExpression(((helper = (helper = lookupProperty

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jackusay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant