wycats / rake-pipeline-web-filters

MIT License
116 stars 36 forks source link

Add :compiler_proc option to HandlebarsFilter #51

Closed ahawkins closed 11 years ago

ahawkins commented 11 years ago

compiler_proc is called with the source. The compiler_proc returns the source by default. You can specify compiler_proc if you want to preprocess the source before it hits wrapper_proc. compiler_proc and wrapper_proc can be set in coordination to do Handlebars precompilation. Here's an example.

# how to precompile handlebars templates
handlebars :wrapper_proc => proc { |source| "Ember.Handlebars.template(#{source});" },
  :compiler_proc => proc { |template| MyCompiler.compile(template) }

I've also updated the docs in this PR.

ahawkins commented 11 years ago

@wycats I gave this a little more thought: do you think it's better to have a separate filter or modify this one? I don't think we need the compiler_proc option anymore. You can do everything with wrapper_proc but it's not obvious how. Is there some way we can make this functionality more obvious?