-
-
Save dudleyf/1557811 to your computer and use it in GitHub Desktop.
AssetFile for Rake Pipeline for use with ember.js/handlebars
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" | |
require "rake-pipeline-web-filters" | |
input "assets" | |
output "public" | |
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 | |
match "*.js" do | |
minispade :module_id_generator => proc { |input| File.basename(input.fullpath, ".js") } | |
concat [ | |
"javascripts/lib/jquery.js", | |
"javascripts/lib/ember.js" | |
], "application.js" | |
end | |
match "*.handlebars" do | |
filter HandlebarsFilter | |
minispade :module_id_generator => proc { |input| File.basename(input.fullpath, ".js") + "_template" } | |
concat "templates.js" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment