Skip to content

Instantly share code, notes, and snippets.

@nicholasjhenry
Created January 4, 2012 00:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicholasjhenry/1557801 to your computer and use it in GitHub Desktop.
Save nicholasjhenry/1557801 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
filter Rake::Pipeline::Web::Filters::MinispadeFilter,
:module_id_generator => proc { |input| File.basename(input.fullpath, ".js") }
filter Rake::Pipeline::OrderingConcatFilter, ["javascripts/lib/jquery.js", "javascripts/lib/ember.js"], "application.js"
end
match "*.handlebars" do
filter HandlebarsFilter
filter Rake::Pipeline::Web::Filters::MinispadeFilter,
:module_id_generator => proc { |input| File.basename(input.fullpath, ".js") + "_template" }
filter Rake::Pipeline::ConcatFilter, "templates.js"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment