render_plugin_views is broken agaisnt Merb edge
Reported by Nolan Darilek | July 1st, 2008 @ 04:09 PM | in 0.5
Merb compiles all its view templates to methods. Apparently, in previous versions, these methods accepted arguments. They don't in edge, however. So in other words, app/helpers/global_helpers.rb:137:
output << send(template_method, options)
needs to pass options some other way.
Comments and changes to this ticket
-

AJ July 2nd, 2008 @ 12:47 AM
- → Tag changed from to compatibility edge feather plugins
- → State changed from new to open
def render_plugin_views(name, options = {}) output = "" Hooks::View.plugin_views.each do |view| if view[:name] == name 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) else # Render the specified text using ERB and the options output << Proc.new { |args| ERB.new(view[:content]).result(binding) }.call(options[:with]) end end end # Return the view markup generated by plugins output endThis badboy needs to be fixed for edge.
wycats also suggested that we did not rely on Merb::Template.template_for's behaviour, as it is a private method and thus likely to change without impunity. He also suggested we use a partial for this behaviour, but I couldn't quite wrap my head around how
perhaps a merb-part? (http://yehudakatz.com/2007/09/06... they mention our exact use case:
1.
Sam Smoot on September 6th, 2007
Can we pull the parts and associated views out into gems to make drop-in components for a range of applications?
2.
wycats on September 7th, 2007
@smoot: yep. by using __FILE__ in your gem to set the _template_root in the part, you should be able to stick parts into gems and then load them via part.
-

-

AJ July 3rd, 2008 @ 08:01 PM
- → Milestone changed from to 0.5
- → Assigned user changed from to AJ
Right, so Ed, Nolan and I played idea tennis, and thought about dynamically loading views from plugins. I'm yet to test/implement this, but as a start, I've fixed the rendering of plugins hooks.
In order to get this working, I make a pretty epic assumption, err, mandate; in your partial hook view, you must reference the object passed (with :with =>) as a downcased, singular version of the object you're passing (Articles => article)
-

AJ July 6th, 2008 @ 07:23 PM
- → Title changed from Merb view template methods no longer accept arguments to render_plugin_views is broken agaisnt Merb edge
Just updating description - spoke to El about this
-

AJ July 6th, 2008 @ 07:39 PM
- → Assigned user changed from AJ to El Draper
-

Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The core code for Feather, a lightweight Merb-based blogging engine.
