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

end

(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
record.errors.full_messages.each
do |m|
li m.gsub(/ id /, ’ ')
end
end
end
end

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
http://www.approachingnormal.com

http://www.welcometoparenthood.com

Larry,

http://api.rubyonrails.org/classes/ActionController/Base.html#M000206

Third example under “Rendering partials”

HTH

John W Higgins

wishdev@gmail.com

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 }

?

-ryan

That's what the third example shows.

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

Thanks,

Jamie

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.