diff --git a/Rakefile b/Rakefile index 1ea64bdf..9bf9b702 100644 --- a/Rakefile +++ b/Rakefile @@ -63,6 +63,7 @@ Rake::RDocTask.new do |rdoc| rdoc.rdoc_files.include('README*') rdoc.rdoc_files.include('lib/**/*.rb') rdoc.rdoc_files.exclude('lib/middleman/features/sprockets+ruby19.rb') + rdoc.rdoc_files.exclude('lib/middleman/templater+dynamic_renderer.rb') end desc "Build and publish documentation using GitHub Pages." diff --git a/lib/middleman/builder.rb b/lib/middleman/builder.rb index 4cd15a6b..02092ff8 100644 --- a/lib/middleman/builder.rb +++ b/lib/middleman/builder.rb @@ -1,4 +1,5 @@ require 'templater' +require 'middleman/templater+dynamic_renderer.rb' require 'rack/test' # Use Rack::Test to access Sinatra without starting up a full server # Placeholder for any methods the builder needs to abstract to allow feature integration @@ -45,35 +46,4 @@ module Middleman add :build, ::Middleman::Builder end -end - -# 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 \ No newline at end of file