Sha256: 74424a8d520d5337f9da0b3fa53b2899b175439b12ff79f2f5bac1d91689c097

Contents?: true

Size: 780 Bytes

Versions: 14

Compression:

Stored size: 780 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
    @@rack_test ||= Rack::Test::Session.new(Rack::MockSession.new(Middleman::Server))
    
    @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::Server.build_dir), "")
      @@rack_test.get(request_path)
      @@rack_test.last_response.body
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
beans-middleman-1.0.14 lib/middleman/templater+dynamic_renderer.rb
beans-middleman-1.0.13 lib/middleman/templater+dynamic_renderer.rb
beans-middleman-1.0.12 lib/middleman/templater+dynamic_renderer.rb
beans-middleman-1.0.11 lib/middleman/templater+dynamic_renderer.rb
beans-middleman-1.0.9 lib/middleman/templater+dynamic_renderer.rb
beans-middleman-1.0.8 lib/middleman/templater+dynamic_renderer.rb
beans-middleman-1.0.7 lib/middleman/templater+dynamic_renderer.rb
beans-middleman-1.0.6 lib/middleman/templater+dynamic_renderer.rb
beans-middleman-1.0.5 lib/middleman/templater+dynamic_renderer.rb
middleman-1.0.0 lib/middleman/templater+dynamic_renderer.rb
middleman-1.0.0.pre lib/middleman/templater+dynamic_renderer.rb
middleman-0.99.3.pre lib/middleman/templater+dynamic_renderer.rb
middleman-0.99.2.pre lib/middleman/templater+dynamic_renderer.rb
middleman-0.99.1.pre lib/middleman/templater+dynamic_renderer.rb