Skip to content

Commit

Permalink
Somehow my render_plugin_views fix was lost in the Ether.
Browse files Browse the repository at this point in the history
From my original commit:

Fixed the render_plugin_views helper to correctly render plugin hooks on
Merb edge.

Unfortunately we have to perform a fairly large assumption here, that is,
we have to assume that you'd like to use the Object being passed (with
:with =>) inside the partial as the singular, downcased version.

e.g., you use <%= render_plugin_views "last_article_in_list",
:with => {:last => @articles.last} %>. In your plugin hook
partial, you *have* to use the singular downcased representation of the
Object(s) you're passing.

Articles => article

11:48 < fujin> e.g. the view I'm testing uses 'article.something',
because it's expecting an Articles to be passed in /as/ 'article'
11:51 < fujin> very hard assumption to make - I either have to
*blanket* say that we'll be passing a singular downcased version of the
Object you're passing to :with
11:51 < fujin> or work out something else to do
11:52 < TheWordNerd> Doesn't seem like a bad assumption.
11:53 < fujin> output << partial(template_location, { :with
=> options[:with], :as =>
options[:with].class.to_s.downcase.singular })
  • Loading branch information
AJ Christensen committed Jul 20, 2008
1 parent d9fdcdc commit 261681f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/helpers/global_helpers.rb
Expand Up @@ -132,9 +132,8 @@ def render_plugin_views(name, options = {})
if view[:partial]
# Set the template root, create the template method and call the partial
_template_root = File.join(view[:plugin].path, "views")
template_location = _template_root / _template_location("_#{view[:partial]}", content_type, view[:name])
template_method = Merb::Template.template_for(template_location)
output << send(template_method, options)
template_location = _template_root / _template_location("#{view[:partial]}", content_type, view[:name])
output << partial(template_location, { :with => options[:with], :as => options[:with].class.to_s.downcase.singular })
else
# Render the specified text using ERB and the options
output << Proc.new { |args| ERB.new(view[:content]).result(binding) }.call(options[:with])
Expand Down

0 comments on commit 261681f

Please sign in to comment.