Created
October 5, 2011 05:53
-
-
Save eivindingebrigtsen/1263749 to your computer and use it in GitHub Desktop.
Raketask for taking mustache files into a js-file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PATH = 'js/tmpl'; | |
desc "make mustache templates" | |
task :mustache do | |
src = 'SB.extend({templates: {'; | |
length = Dir[PATH+'/*.mustache'].length; | |
Dir[PATH+'/*.mustache'].each do |f| | |
file = File.open(f, 'rb').read(); | |
file.gsub!(/\n|\r|\t|\s\s/, '') | |
src += '"'+File.basename(f).gsub(/\.mustache/, '')+ '"' + " : '" + file + "',"; | |
end | |
src += '"done":true}});'; | |
File.open('js/src/templates.js', 'wb'){|io| io.write(src) } | |
puts "Saved " + length.to_s + ' templates' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment