Skip to content

Instantly share code, notes, and snippets.

@dudleyf
Forked from nicholasjhenry/AssetFile
Created January 4, 2012 00:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dudleyf/1557811 to your computer and use it in GitHub Desktop.
Save dudleyf/1557811 to your computer and use it in GitHub Desktop.
AssetFile for Rake Pipeline for use with ember.js/handlebars
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