Skip to content

Instantly share code, notes, and snippets.

@rfunduk
Created August 16, 2011 16:23
Show Gist options
  • Save rfunduk/1149469 to your computer and use it in GitHub Desktop.
Save rfunduk/1149469 to your computer and use it in GitHub Desktop.
<div id="footer">
This site is Copyright &copy; 2008 - blah, blah, blah
</div>
<div id="footer"><%= partial 'footer' %></div>
require 'erb'
def write_output( filename, result )
filename = filename.split( '/' ).last
File.open( filename, 'wb' ).write( result )
puts "WROTE : #{filename}"
end
def partial( name )
filename = "sources/#{name}.partial"
if File.exists? filename
puts "LOADED : #{name}.partial"
File.open( filename, 'rb' ).read.chomp
else
puts "ERROR : #{filename}"
end
end
task :build do
sources = FileList["sources/*.*"].exclude( "sources/*.partial" )
sources.each do |f|
puts "\nCOMPILING : #{f}"
page = ERB.new( File.open( f, 'rb' ).read )
write_output f, page.result
end
end
task :default => [ :build ]
COMPILING : sources/simple-partials.html
LOADED : 1.html.partial
LOADED : 2.html.partial
LOADED : 3.rb.partial
LOADED : 4.txt.partial
WROTE : simple-partials.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment