Best Way to Write Helpers Using Markaby?

Ethan Winn ethan at echoditto.com
Mon Nov 26 00:21:08 EST 2007


Hey there Merbers,

I'm a Merb neophyte checking it out with a simple app exploration  
after being inspired by Mr. Katz's presentation @ JQueryCamp and with  
the desire to use Markaby if at all possible (I heart camping). I've  
done a little exploration of how to use Markaby in helper code, but  
any guidance would definitely be appreciated (I definitely do not  
understand the "Merb way").

At first I tried just putting the `tag_name do` blocks right in my  
helpers, but this didn't work out.  What I've found does work is  
wrapping this code in `Markaby::Builder.new.html do` blocks, such as  
this:

     def tasks_table tasks
       Markaby::Builder.new.html do
         p "update tasks below"
         table do
           tasks.each do |task|
             task_row(task)
           end
         end
       end
     end

While this works, I'm pretty sure that making a new builder instance  
for each helper call.

What's the "right" way?

Thanks.

--
Ethan Winn
ethan at echoditto.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/merb-devel/attachments/20071126/07cd40a9/attachment.html 


More information about the Merb-devel mailing list