2009-10-22 20:25:15 -04:00
|
|
|
require 'rack/test' # Use Rack::Test to access Sinatra without starting up a full server
|
|
|
|
|
|
|
|
# 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
|
2010-09-05 22:28:38 -04:00
|
|
|
@@rack_test ||= Rack::Test::Session.new(Rack::MockSession.new(Middleman::Server))
|
2009-10-29 12:17:15 -04:00
|
|
|
|
2009-10-22 20:25:15 -04:00
|
|
|
@render_cache ||= begin
|
|
|
|
# The default render just requests the page over Rack and writes the response
|
2010-09-05 22:28:38 -04:00
|
|
|
request_path = destination.gsub(File.join(Dir.pwd, Middleman::Server.build_dir), "")
|
2009-10-29 12:17:15 -04:00
|
|
|
@@rack_test.get(request_path)
|
|
|
|
@@rack_test.last_response.body
|
2009-10-22 20:25:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|