Markaby or erb?

Guys,

We’re embarking on a new dev project, and I’m curious…why would one
choose markaby over erb? I for one am no fan of the erb syntax, but
aside from that it’s similar to other technologies I’ve used in the
past: PHP, JSP, ASP, etc.

Why would one choose markaby over erb? What are the benefits? What are
the drawbacks? Is there anything remarkable one can do that the other
can’t?

Look for general experience and insight.

Thank you!
JB

On 25 Apr 2006 00:58:50 -0000, John W.
[email protected] wrote:

Look for general experience and insight.

One nice thing about Markaby is that it won’t let you (well, not
easily) write invalid XHTML. The Ruby parser will complain first.
Also, if much of your ERb template was Ruby code anyway, it might be
easier to write and read in Markaby.

Personally, I don’t really feel that the API has stabilized yet, and I
haven’t used it for any ‘real’ projects. I really like the idea,
though, and I think it will be awesome before it gets to 1.0. I know
others have already made extensive use of it, though, so hopefully
someone else will chime in.

–Wilson.

John W. <devlists-rubyonrails@…> writes:

Look for general experience and insight.

Thank you!
JB

I’m considering using both. Erb is more natural for a page which is
mostly
just html, but starts to look real nasty when the page has lots of ruby.
If you take the mostly-ruby page and use markaby, it’ll come
out real nice and elegant.

jeem

jeem wrote:

John W. <devlists-rubyonrails@…> writes:

Look for general experience and insight.

Thank you!
JB

I’m considering using both. Erb is more natural for a page which is
mostly
just html, but starts to look real nasty when the page has lots of ruby.
If you take the mostly-ruby page and use markaby, it’ll come
out real nice and elegant.

jeem

I have a query. Previously I’ve used Markaby as a plugin but now want to
install the gem version. With the gem, how do I ensure in Rails that
Markaby is called by the various layouts in .mab format?

guy

I’m considering using both. Erb is more natural for a page which is mostly
just html, but starts to look real nasty when the page has lots of ruby.
If you take the mostly-ruby page and use markaby, it’ll come
out real nice and elegant.

ERb is giving you feedback about the quality of your templates. If it
starts to “look real nasty”, your templates have too much logic, and
you should refactor. Either by pulling true template logic into
helpers or by pulling controller/model logic out of there. Usually a
combination of the two.

Using something like Markaby to cover up the information that ERb is
giving you about the state of your templates doesn’t seem like the way
to go to me. Choose Markaby because you feel its a better way of
structuring HTML, not because it makes it easier to gloss over the
fact that your templates are overburdened with concerns.

David Heinemeier H.
http://www.loudthinking.com – Broadcasting Brain
http://www.basecamphq.com – Online project management
http://www.backpackit.com – Personal information manager
http://www.rubyonrails.com – Web-application framework

you need to set up the handling in environment.rb

Enable Markaby Templates

require ‘markaby’
ActionView::Base::register_template_handler ‘mab’, Markaby::View

will do the trick

be warned, i’ve had some issues with the latest version (0.4) that i
havent
been able to resolve/get resolved - i’ve currently reverted to the 0.3
tag as
a plugin which works as expected; iirc the gem is now 0.4 (it gets
installed
with camping) - it broke flash for me (multiple outputting of messages
along
with the key name, i.e ‘noticeSomeMessageSomeMessage’ instead of
‘SomeMessage’)