# Markaby or erb?

**URL:** <https://www.ruby-forum.com/t/markaby-or-erb/58705>\
**Category:** Rails\
**Created:** [April 25, 2006, 3:00am UTC](https://www.ruby-forum.com/t/markaby-or-erb/58705 "2006-04-25T03:00:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [April 25, 2006, 3:00am UTC](https://www.ruby-forum.com/t/markaby-or-erb/58705/1 "2006-04-25T03:00:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [April 25, 2006, 4:35am UTC](https://www.ruby-forum.com/t/markaby-or-erb/58705/2 "2006-04-25T04:35:06Z")

</div>

On 25 Apr 2006 00:58:50 -0000, John W.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [April 25, 2006, 4:47am UTC](https://www.ruby-forum.com/t/markaby-or-erb/58705/3 "2006-04-25T04:47:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [April 25, 2006, 6:06pm UTC](https://www.ruby-forum.com/t/markaby-or-erb/58705/4 "2006-04-25T18:06:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [April 25, 2006, 6:45pm UTC](https://www.ruby-forum.com/t/markaby-or-erb/58705/5 "2006-04-25T18:45:28Z")

</div>

> 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](http://www.loudthinking.com) – Broadcasting Brain  
[http://www.basecamphq.com](http://www.basecamphq.com) – Online project management  
[http://www.backpackit.com](http://www.backpackit.com) – Personal information manager  
[http://www.rubyonrails.com](http://www.rubyonrails.com) – Web-application framework

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [April 25, 2006, 6:23pm UTC](https://www.ruby-forum.com/t/markaby-or-erb/58705/6 "2006-04-25T18:23:41Z")

</div>

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’)
