Created
February 28, 2010 04:14
Revisions
-
bryanlarsen revised this gist
Feb 28, 2010 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ module Dryml class TemplateHandler < ActionView::Template::Handler def self.call(template) "renderer = Dryml.page_renderer(self, local_assigns.keys, '#{template.details[:virtual_path]}', '#{template.identifier}') this = self.controller.send(:dryml_context) || local_assigns[:this] @this ||= this s = renderer.render_page(@this, local_assigns) # Important to strip whitespace, or the browser hangs around for ages (FF2) s.strip" end end end -
bryanlarsen created this gist
Feb 28, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ module Dryml # quacks like a Rails3 ActionView::Template class MissingTemplate attr_reader :details def identifier "#{@prefix}/#{@name}" end def mime_type details[:mime_type] end def initialize(name, details, prefix, partial) @name = name @details = details @prefix = prefix @partial = partial end def render(view, locals, &block) renderer = Dryml.empty_page_renderer(view) renderer.render_tag("#{@name}-page", locals) end end class FallbackResolver < ActionView::Resolver def find_templates(*args) [Dryml::MissingTemplate.new(*args)] end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ ActionView::Template.register_template_handler(:dryml, Dryml::TemplateHandler) ActionController::Base.view_paths << Dryml::FallbackResolver.new