Easy way to precompile Emberjs Handlebar templates with nodejs?

前端 未结 8 1717
耶瑟儿~
耶瑟儿~ 2021-02-01 09:59

I\'m enjoying emberjs a lot and would like to take the next step in a couple of my small, mobile apps and precompile my Ember/Handlebars templates as part of my build process.

8条回答
  •  别那么骄傲
    2021-02-01 10:24

    I wrote an official precompiler npm module for anyone else who might be wanting to do this w/ a recent version of ember.js

    https://npmjs.org/package/ember-template-compiler

    It's simple to install and use (example below)

    npm install ember-template-compiler

    var compiler = require('ember-template-compiler');
    var template = fs.readFileSync('foo.handlebars').toString();
    var input = compiler.precompile(template).toString();
    var output = "Ember.TEMPLATES['foo'] = Ember.Handlebars.template(" + input + ");";
    

提交回复
热议问题