templating choice

0 views
Skip to first unread message

Paul Walker

unread,
Nov 21, 2009, 12:44:50 AM11/21/09
to sina...@googlegroups.com

HAML seems to be the most popular choice of rubyists, but I fail to
understand why. I don't understand the desire to put markup in some
pseudo wiki format that the front end portion of my team would have to
learn. Is the Haml draw that of those that don't like to concern
themselves with the actual markup? Is it one of those that desire to
all logic in ruby code?

I've been using erubis: http://www.kuwata-lab.com/erubis/ and am
satisfied with everything except that I can't call sinatra helpers
within the templates (although I can call functions defined in the top
DSL).

I'd like to hear your thoughts on template libraries and why you're
using what you are :-).

~Paul

Kurtis Rainbolt-Greene

unread,
Nov 21, 2009, 2:08:01 AM11/21/09
to sina...@googlegroups.com
HTML markup was poorly designed and horrible to learn. HAML makes HTML a lot easier to learn and utilize. It's not perfect by any shot, because it still has to conform somewhat to HTML.


--

You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To post to this group, send email to sina...@googlegroups.com.
To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=.



Danny Tatom

unread,
Nov 21, 2009, 2:10:49 AM11/21/09
to sina...@googlegroups.com
I use HAML seemply 'cause of its sex appeal. Plus, as Kurtis said, HTML is just plain horrid. And the syntax is easy enough that it shouldn't take a designer too long to get comfortable with it.

--

You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To post to this group, send email to sina...@googlegroups.com.
To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=.





--
Danny Tatom
http://dannytatom.com

Paul Walker

unread,
Nov 21, 2009, 2:36:57 AM11/21/09
to sina...@googlegroups.com
But, whatever your doctype of choice, you still should be concerned with the exact markup no?

Michel Martens

unread,
Nov 21, 2009, 6:04:18 AM11/21/09
to sina...@googlegroups.com
Hey,

On Sat, Nov 21, 2009 at 2:44 AM, Paul Walker <pjwa...@gmail.com> wrote:
>
> HAML seems to be the most popular choice of rubyists, but I fail to
> understand why.  I don't understand the desire to put markup in some
> pseudo wiki format that the front end portion of my team would have to
> learn.  Is the Haml draw that of those that don't like to concern
> themselves with the actual markup?  Is it one of those that desire to
> all logic in ruby code?

It's not pseudo wiki, actually it's simplified HTML (you get to type
half of it).

You can represent HTML in many ways (Haml, s-expressions, Ruby blocks,
etc.), and every time the idea is to type less and make the code more
clear.

> I've been using erubis: http://www.kuwata-lab.com/erubis/ and am
> satisfied with everything except that I can't call sinatra helpers
> within the templates (although I can call functions defined in the top
> DSL).
>
> I'd like to hear your thoughts on template libraries and why you're
> using what you are :-).

I started with Erb, but moved to Haml once I realized I could
accomplish the same with less typing and less noise.

Haml is very strict with the parsing and indentation, so IMO it yields
better markup than handwritten HTML/Erb. The HTML/CSS guys I know can
work with templates in Haml and they love it, even if they don't know
a bit of Ruby.

--
Michel

Roland Swingler

unread,
Nov 21, 2009, 6:30:08 AM11/21/09
to sina...@googlegroups.com
> HAML seems to be the most popular choice of rubyists

I wouldn't say this was true, at least amongst london Rubyists. I
think the desire to use non-erb based templating languages stems from
the fact that you have to be really disciplined to avoid inappropriate
logic in your views. There is also (in my opinion) something nasty
about interpolation-based template systems when you're really trying
to build a tree.

> I'd like to hear your thoughts on template libraries and why you're
> using what you are

At work erb :) but mainly because everyone knows it. Out of work I
really like erector: http://github.com/pivotal/erector but I'm
interested in looking into Effigy as well
http://github.com/jferris/effigy

HTH
Roland

Alex Chaffee

unread,
Nov 21, 2009, 11:43:50 AM11/21/09
to sina...@googlegroups.com, sina...@googlegroups.com
Erector FTW

http://erector.rubyforge.org


Sent from my iPhone

Chris Wanstrath

unread,
Nov 21, 2009, 12:56:04 PM11/21/09
to sina...@googlegroups.com
On Friday, November 20, 2009, Paul Walker <pjwa...@gmail.com> wrote:

> HAML seems to be the most popular choice of rubyists,

It's the most popular non-standard library library, but ERB still dominates.

> I'd like to hear your thoughts on template libraries and why you're
> using what you are :-).

We're writing all our new code in Mustache:

http://github.com/defunkt/mustache

Chris

--
Chris Wanstrath
http://github.com/defunkt

Jason Rogers

unread,
Nov 21, 2009, 1:11:37 PM11/21/09
to sina...@googlegroups.com
+1 for Mustache

I also like good ol' Builder.
> --
>
> You received this message because you are subscribed to the Google Groups "sinatrarb" group.
> To post to this group, send email to sina...@googlegroups.com.
> To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=.
>
>
>



--
Jason Rogers

"I am crucified with Christ: nevertheless I live;
yet not I, but Christ liveth in me: and the life
which I now live in the flesh I live by the faith of
the Son of God, who loved me, and gave
himself for me."
Galatians 2:20

Paul Walker

unread,
Nov 22, 2009, 12:19:40 PM11/22/09
to sina...@googlegroups.com
Mustache looks interesting...having a stateful class for each view is
very bueno, much like asp.net, java frameworks. Been playing with it
a bit and have some questions I've posted to it's group :-).

Thanks for the feedback :-)

~Paul

Christer Nilsson

unread,
Nov 22, 2009, 3:51:34 PM11/22/09
to sina...@googlegroups.com
+1 for Haml.
 
Haml shows most information per screen.
And demands correct indentation, which is good.
 
The output is always correct indented and can be suppressed for production use.
 
Haml gives good separation between code and gui design, which is important.
(I've seen html generated in SQL stored procedures, that is ugly and breaks the MVC rules)
 
I've tried using haml+ruby instead of xsl and got a 75 % reduction in code volume. (And got rid of ugly xml programming in xslt as well)
 
Ruby programming in Haml is endless, like Python. It is hopefully just a matter of time before "end" is dropped from normal Ruby as well.
Both formats can be accepted in the transient period.
 
/Christer

Richard

unread,
Nov 24, 2009, 1:12:36 PM11/24/09
to sinatrarb
Thanks for this topic -- been playing with Mustache and I really like
it. I still love HAML's quick and clean syntax though. If only could
have Mustache with HAML's HTML syntax :)

But I am really starting to see the goodness of the View classes and
keeping templates as, well, pure HTML templates. Still, I think HAML
is great especially for quick and clean HTML writing.
Reply all
Reply to author
Forward
0 new messages