Sha256: d2bdfab0c6f835c1be58670b4e8f833a5d388bea6ac2c47a3949f006aa8b1fe2

Contents?: true

Size: 759 Bytes

Versions: 5

Compression:

Stored size: 759 Bytes

Contents

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
    @render_cache ||= begin
      # 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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
middleman-0.9.23 lib/middleman/templater+dynamic_renderer.rb
middleman-0.9.22 lib/middleman/templater+dynamic_renderer.rb
middleman-0.9.21 lib/middleman/templater+dynamic_renderer.rb
middleman-0.9.20 lib/middleman/templater+dynamic_renderer.rb
middleman-0.9.18 lib/middleman/templater+dynamic_renderer.rb