1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/lib/middleman/templater+dynamic_renderer.rb
2009-10-08 11:05:53 -07:00

30 lines
No EOL
839 B
Ruby

# Monkey-patch to use a dynamic renderer
class Templater::Actions::File
def identical?
if exists?
return true if File.mtime(source) < File.mtime(destination)
FileUtils.identical?(source, destination)
else
false
end
end
end
class Templater::Actions::Template
def render
# The default render just requests the page over Rack and writes the response
request_path = destination.gsub(File.join(Dir.pwd, Middleman::Base.build_dir), "")
browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Base))
browser.get(request_path)
browser.last_response.body
end
def identical?
if File.exists?(destination)
return true if File.exists?(source) && File.mtime(source) < File.mtime(destination)
File.read(destination) == render
else
false
end
end
end