Created
April 27, 2012 13:55
-
-
Save huyderman/2509486 to your computer and use it in GitHub Desktop.
A rake snippet for auto-erb goodness
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
class TiltHelper | |
def initialize(prefix) | |
@prefix = prefix | |
end | |
def include(partial) | |
Tilt.new("#{@prefix}/#{partial}").render | |
end | |
end | |
rule( /\.((?!erb$)([A-Za-z0-9]))+$/ => | |
[ proc { |t| "#{t}.erb" }, | |
proc { |t| FileList.new t.pathmap("%X/*.*")}]) do |t| | |
puts "Processing ERB Template #{t.source} => #{t.name}" | |
template = Tilt.new t.source | |
helper = TiltHelper.new t.name.pathmap "%X" | |
file = File.new t.name, 'w' | |
file.write template.render helper | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment