Open dudleyf opened 12 years ago
The following filter ( not the nicest solution ) works for my case. Based on this filter, i would recommend to provide a pre/post generate_output methods to be overridden on filter definitions.
class PrecompiledHandlebarsFilter < Rake::Pipeline::Filter
attr_writer :counter
def initialize(&block)
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') }
super(&block)
@counter = 0
end
def generate_output(inputs, output)
if ( @counter == 0 )
output.write "minispade.require(\"handlebars\");\n"
output.write "minispade.require(\"ember-debug\");\n"
output.write "minispade.require(\"ember-metal\");\n"
output.write "minispade.require(\"ember-runtime\");\n"
output.write "minispade.require(\"ember-views\");\n"
output.write "minispade.require(\"ember-states\");\n"
output.write "minispade.require(\"metamorph\");\n"
output.write "minispade.require(\"ember-handlebars\");\n"
end
@counter += 1
inputs.each do |input|
output.write %x( handlebars #{input.fullpath} )
end
if ( @counter == @input_files.length )
output.write "for( var i in Handlebars.templates ) { if ( Handlebars.templates.hasOwnProperty(i) ) { Ember.TEMPLATES[i] = Handlebars.templates[i]; } }\n"
end
end
end
Maybe this can be to some use: https://github.com/tchak/rasputin
We need a Handlebars precompile filter a la: http://handlebarsjs.com/precompilation.html.