Skip to content

Commit

Permalink
DRYML - template handler updated for Rails 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tslocke committed Jun 17, 2008
1 parent b8ad949 commit a8dc5de
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 35 deletions.
1 change: 0 additions & 1 deletion hobo/Manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
bin/hobo
CHANGES.txt
init.rb
lib/action_view_extensions/base.rb
lib/active_record/association_proxy.rb
lib/active_record/association_reflection.rb
lib/active_record/has_many_association.rb
Expand Down
15 changes: 0 additions & 15 deletions hobo/lib/action_view_extensions/base.rb

This file was deleted.

6 changes: 1 addition & 5 deletions hobo/lib/hobo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,8 @@ def enable
require 'active_record/has_many_through_association'
require 'active_record/association_proxy'
require 'active_record/association_reflection'
require 'action_view_extensions/base'

ActionView::Base.register_template_handler("dryml", Hobo::Dryml::TemplateHandler)
# TODO - Rails 2.1 requires ActionView::Template
# ActionView::Template.register_template_handler("dryml", Hobo::Dryml::TemplateHandler)

ActionView::Template.register_template_handler("dryml", Hobo::Dryml::TemplateHandler)

Hobo.developer_features = RAILS_ENV.in?(["development", "test"]) if Hobo.developer_features?.nil?

Expand Down
6 changes: 5 additions & 1 deletion hobo/lib/hobo/dryml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ def empty_page_renderer(view)
end


def page_renderer_for_template(view, template)
page_renderer(view, template.locals.keys, template.path_without_extension)
end


def page_renderer(view, local_names=[], page=nil)
if RAILS_ENV == "development"
clear_cache
Taglib.clear_cache
end
page ||= view.instance_variable_get('@hobo_template_path')

prepare_view!(view)
included_taglibs = ([subsite_taglib(page)] + controller_taglibs(view.controller.class)).compact
Expand Down
5 changes: 0 additions & 5 deletions hobo/lib/hobo/dryml/template_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ def scope
end


def attr_extension(s)
AttributeExtensionString.new(s)
end


def dom_id(object=nil, attribute=nil)
if object.nil?
# nothing passed -- use context
Expand Down
12 changes: 4 additions & 8 deletions hobo/lib/hobo/dryml/template_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ module Hobo::Dryml

class TemplateHandler < ActionView::TemplateHandler

def initialize(view)
@view = view
end

def render(src, local_assigns)
renderer = Hobo::Dryml.page_renderer(@view, local_assigns.keys)
this = @view.instance_variable_set("@this", @view.controller.send(:dryml_context) || local_assigns[:this])
s = renderer.render_page(this, local_assigns)
def render(template)
renderer = Hobo::Dryml.page_renderer_for_template(@view, template)
this = @view.instance_variable_set("@this", @view.controller.send(:dryml_context) || template.locals[:this])
s = renderer.render_page(this, template.locals)

# Important to strip whitespace, or the browser hangs around for ages (FF2)
s = s.strip
Expand Down

0 comments on commit a8dc5de

Please sign in to comment.