-
-
Save dudleyf/1477124 to your computer and use it in GitHub Desktop.
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 |
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.
@dudleyf With this method how is a template assigned to a View?
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.
why don't create a file which appends:
On this way, set up the view looks like better.
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.