Skip to content

Instantly share code, notes, and snippets.

Created Dec 14, 2011
What would you like to do?
Handlebars Rake::Pipeline filter
require "json"
class HandlebarsFilter < Rake::Pipeline::Filter
def initialize(&block)
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') }
def generate_output(inputs, output)
inputs.each do |input|
output.write "return Ember.Handlebars.compile(#{})"
Copy link

ppcano commented Dec 14, 2011

why don't create a file which appends:

output.write "Ember.TEMPLATES[filenamewithout_handlebars_extension] =  Ember.Handlebars.compile(#{})"

On this way, set up the view looks like better.

        templateName: 'filenamewithout_handlebars_extension'

What i don't really understand is the purpose of minispade????, could you give me a explanation?,

i know i have been using minispade for testing with bpm, but now i don't really get the point if minispade is required or not.

Last day, i could not mount my project with rakepipeline, and so far the hosting was node backend, i deployed my project without rakepipeline and emulate the pipeline behaviour with node tools.

That is the reason, why i am interesting to know which is the purpose of minispade, perhaps i am missing something i don't still know.

Copy link

dudleyf commented Dec 14, 2011

Minispade just lets you require your javascript in a different order than the order of your js files. If you use minispade you can concatenate all your javascript without worrying about what order the files get included, then use minispade to load what you need when you need it. If you have another way you're comfortable with managing the load order of your javascript, feel free to do that. You don't have to use minispade. You could definitely change the filter to add your templates to Ember.TEMPLATES if you wanted to. I prefer not to, since that means I have to make sure that whatever file that code gets written to gets loaded before the code that uses the template. With minispade, I don't have to worry about what files get loaded first, I just require a module when I need it.

Copy link

nicholasjhenry commented Jan 3, 2012

@dudleyf With this method how is a template assigned to a View?

Copy link

dudleyf commented Jan 3, 2012

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