I need to scan and compile a nested templates folder when the server starts. For that I’m using ember-skeleton. The following routine in Assetfile does well the job of scanning and compiling handlebars file as long as they are all in the templates folder.
match 'templates/**/*.handlebars' do
filter HandlebarsFilter
filter TemplateFilter,
#filter LoaderFilter,
:module_id_generator => proc { |input|
#input.path.sub(/^templates\//, "#{APPNAME}/~templates/").sub(/\.handlebars$/, '')
input.path.sub(/^templates\//, "").sub(/\.handlebars$/, '')
}
if ENV['RAKEP_MODE'] == 'production'
uglify {|input| input}
end
concat 'app.js'
end
My list of file is getting larget by the ay and I want to classify files into folders such as
templates/products/
templates/products/index.handlebars
templates/products/new.handlebars
templates/products/edit.handlebars
templates/files/
templates/files/index.handlebars
templates/files/new.handlebars
templates/files/edit.handlebars
I want to modify the code listed above to be able to scan for handlebars files one level deeper, and execute the filter against the entries. This should be quite easy for someone who’s acquainted with Ruby or Rails.
I tried with no luck the following, Also anyone can tell me how to debug such a routine, i tried to do a print input within the routine, the server crashed on me though 🙂
match 'templates/**/**/*.handlebars' do
Turns out
match 'templates/**/*.handlebars' dois already taking care of scanning nested folders and there is not need to modify it, all i had to do is reflect the hierarchy in my template name