Using partials with Markaby

I’m trying to use a partial from within Markaby. I haven’t been able to figure out how to access a parameter passed into the partial. Here’s the code I’m using:

h1 “Create a new note”

if @note
render :partial => ‘form/errors’, :record => @note


(that snippet, as well as the partial is stolen shamelessly from Restolog (thought converted to Markaby), which is a nice example of a REST-ful rails app)

here’s the partial, in form/_errors.mab:

unless record.nil? or record.errors.empty?
div :class => “message-error” do
p “The #{record.class.to_s.downcase} could not be saved:”

ul do
do |m|
li m.gsub(/ id /, ’ ')

The error I get is this:

notes/vendor/plugins/markaby/lib/markaby/builder.rb:203:in `method_missing': no such method `record'

Anyone know what I’m missing here? I suspect that there’s a special way to access parameters in partials for Markaby, but I haven’t been able to figure out what it is.

Try putting parens around everything after "render"

Nope, no dice. Thanks for the suggestion though.

try passing a hash:

render({:partial => 'form/errors', :record => @note})

Still no, unfortunately.

Larry Wright


Third example under “Rendering partials”


John W Higgins

what about:

render_partial('form/errors', @note)

if that fails, try:
helpers.render_partial('form/errors', @note)

That did the trick. Thanks!

Why not:

render :partial => 'form/errors', :locals => {:record => @note }



That's what the third example shows.

Hey Larry, I'm curious about your general experiences and impressions of using Markaby instead of ERb.



I like it. General impressions are that it’s cleaner than ERB. I’m not working with a designer, though. If I were, I might use ERB instead as it seems like that would be easier for a designer to work with.

My only frustration is the lack of documentation, particularly around things that work differently than ERB (such as this partial thing).

Other than that, I like it better than ERB. It certainly means less angle-bracket typing, which is nice.