meteor / standalone-blaze-generator

10 stars 7 forks source link

Question: Is this the best way to get a standalone Blaze/Spacebars js file? #1

Closed cmather closed 10 years ago

cmather commented 10 years ago

Use case: Update the npm em command line tool to use Spacebars/Blaze for the templates instead of ejs.

Reqs:

  1. Get Spacebars/Blaze into a js file and add it to the npm package
  2. Compile a template into javascript (it may be text in addition to html, which might not be possible)
  3. Render the text with a data context

Code: https://github.com/EventedMind/em/blob/devel/lib/generator.js#L46

avital commented 10 years ago

Yeah, this is what we used to build stand-alone Blaze (meteor.github.io/blaze/). Your approach should probably work fine, but take into account that the HTML passed into spacebars-compiler must be valid HTML. We actually use this approach to generate boilerplate HTML: https://github.com/meteor/meteor/blob/devel/packages/boilerplate-generator/boilerplate-generator.js#L24