Skip to content

Instantly share code, notes, and snippets.

@khamidou
Created February 3, 2012 19:39
Show Gist options
  • Save khamidou/1731966 to your computer and use it in GitHub Desktop.
Save khamidou/1731966 to your computer and use it in GitHub Desktop.
Rakefile to concatenate templates and js files together
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