#18 ✓resolved
Nolan Darilek

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

    AJ July 2nd, 2008 @ 12:47 AM

    • State changed from “new” to “open”
    • Tag set to compatibility, edge, feather, plugins
    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
        end
    

    This 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.

    http://merbivore.com/documentati...

    http://merbivore.com/documentati...

  • AJ
  • AJ

    AJ July 3rd, 2008 @ 08:01 PM

    • Milestone set to 0.5
    • Assigned user set 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)

    http://github.com/fujin/feather/...

  • AJ

    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

    AJ July 6th, 2008 @ 07:39 PM

    • Assigned user changed from “AJ” to “Elliott Draper”
  • AJ

    AJ July 20th, 2008 @ 07:50 AM

    • State changed from “open” to “resolved”

    Fixed in edge branch.

    http://github.com/mleung/feather...

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

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.

People watching this ticket

Pages