Created
February 3, 2012 19:39
-
-
Save khamidou/1731966 to your computer and use it in GitHub Desktop.
Rakefile to concatenate templates and js files together
This file contains hidden or 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
require 'rake' | |
task :default => :compile_templates | |
task :clean_compiled_file do | |
if File.exist?('release.js') | |
File.unlink('release.js') | |
end | |
end | |
task :compile_js => :clean_compiled_file do | |
out = "" | |
Dir['js/*'].each do |file| | |
out += File.read(file) | |
end | |
File.open("release.js", 'a') { |file| | |
file.write(out) | |
} | |
puts "done concatenating files" | |
end | |
task :compile_templates => :compile_js do | |
templates = "" | |
Dir['templates/*'].each do |file| | |
templates += "Minitape." + File.basename(file).split(".")[0] + "_template = \"" + File.read(file).gsub("\n", "").gsub(" ", "") + "\";" | |
end | |
File.open("release.js", 'a') { |file| | |
file.write(templates) | |
} | |
puts "done compiling templates" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment