Easy way to precompile Emberjs Handlebar templates with nodejs?

前端 未结 8 1733
耶瑟儿~
耶瑟儿~ 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:07

    Look at the code for the official ember-rails gem at https://github.com/emberjs/ember-rails

    While it's not a node.js project, it does show you how to precompile the templates using the Rails 3.1+ asset pipeline, and it includes all the necessary Javascript code that you would need to do it in Node without having to hack together a solution that you'd have to maintain on your own.

    More specifically, look at vendor/assets/javascripts/ember-precompiler.js and lib/ember-rails/hjs_template.rb

    I'm far from an expert on Node (obviously, Rails is more my thing).. but I think those two files should point you in the right direction. Basically, you're going to want to concatenate ember-precompiler.js (which acts as a "shim" for lack of a better word) with ember.js and then call EmberRails.precompile to compile your templates.

提交回复
热议问题