Created
December 14, 2011 15:52
-
-
Save dudleyf/1477124 to your computer and use it in GitHub Desktop.
Handlebars Rake::Pipeline filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "json" | |
class HandlebarsFilter < Rake::Pipeline::Filter | |
def initialize(&block) | |
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') } | |
super(&block) | |
end | |
def generate_output(inputs, output) | |
inputs.each do |input| | |
output.write "return Ember.Handlebars.compile(#{input.read.to_json})" | |
end | |
end | |
end |
Given a template in lib/templates/myview.handlebars
:
MyView = Ember.View.extend({
template: minispade.require('lib/templates/myview.js')
})
That's not necessarily the right way to do it, it's just the way I did it :) We'll hopefully have a HandlebarsFilter in rake-pipeline-web-filters fairly soon that will do it the right way.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dudleyf With this method how is a template assigned to a View?