Created
April 11, 2011 07:22
-
-
Save eivindingebrigtsen/913185 to your computer and use it in GitHub Desktop.
make mustache templates into a javascript object
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
desc "make mustache templates" | |
task :mustache do | |
src = 'window.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