Sha256: 2bbeafb82f925360890e9799a793b4567e2a138e1f65888c90819e7c759bba3f

Contents?: true

Size: 839 Bytes

Versions: 4

Compression:

Stored size: 839 Bytes

Contents

# 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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
middleman-0.9.14 lib/middleman/templater+dynamic_renderer.rb
middleman-0.9.13 lib/middleman/templater+dynamic_renderer.rb
middleman-0.9.12 lib/middleman/templater+dynamic_renderer.rb
middleman-0.9.11 lib/middleman/templater+dynamic_renderer.rb