[ANN] Haml 1.5!

16 views
Skip to first unread message

Nathan Weizenbaum

unread,
Mar 13, 2007, 9:49:50 PM3/13/07
to ha...@googlegroups.com
Hello, fellow Hamlites,

Haml 1.5 has been released! Download the new version and give it a try:
"./script/plugin install http://hamptoncatlin.com/svn/haml/tags/stable"
for Rails, or just "gem install haml" if you want it on its own. It's
absolutely worth the update. Along with plenty of bug fixes, version 1.5
adds various usefull and snazzy features to Haml. But the biggest news
in 1.5 isn't a new feature: it's an entirely new templating engine.

You see, after using Haml for a while, one tends to get used to the idea
that markup can, indeed /should/, be beautiful and concise. Other, less
elegant markup languages begin to seem a little grating. While working
on a stylesheet, one might think "I can right HTML in an elegant manner.
Why can't I do the same thing with CSS?" Well, we thought that, too. So
we came up with a solution: Syntactically Awesome StyleSheets, or "Sass."

Sass is a templating engine for CSS that's bundled along with Haml 1.5.
It allows you to write CSS using the same elegant whitespace-sensitive
style used in Haml. It eliminates the redundancy formerly inherent in
nesting CSS styles, using "namespace" styles such as font-family and
font-weight, re-using the same value, and even writing out CSS rules.
Just stick your ".sass" files in "public/stylesheets/sass", and
corresponding ".css" files will be created whenever you need them to be.
You can read all about it at http://haml.hamptoncatlin.com/docs/sass/ref
(not quite up as of the sending of this email... wait half an hour, and
it will be), but here's a sample to get you interested:

!main_color = #82fc08

#main
:width 80%
:color = !main_color
:font
:family sans-serif
:size 1.3em

p
:color = !main_color - #404040
:font-size 0.8em

This compiles to

#main {
width: 80%;
color: #82fc08;
font-family: sans-serif;
font-size: 1.3em; }
#main p {
color: #42bc00;
font-size: 0.8em; }

Now, of course Sass is all exciting and wonderful, but what about those
new Haml features I was mentioning? Well, they're delightful as well.
For instance, Haml now does error handling. Before 1.5, invalid input
wouldn't cause an error; it would just produce undefined, often very
strange, output. This was the cause of many confusing issues for many
people, even those of us who created Haml. Haml 1.5, however, checks for
syntax errors, and will notify you exactly what went wrong and where in
the document the error occurred, in a way that Rails can then format as
a good old error page.

Haml 1.5 also adds a new type of command: filters, which use the ":"
character followed by the name of the filter. Filters take an indented
block of text and pass it through some sort of text processor,
independent of Haml, and insert the result (as properly indented as
possible) into the Haml document. For example, if you wanted to add some
"humane" markup to your document using Textile, you could do:

.content
:textile
h1. Blah!

Blah. Blah blah blah blah, blah blah blah.
*Blah* blah blah, blah bl-blah blah blah.

_Blah_ blah blah blah.

This would compile to:

<div class='content'>
<h1>Blah!</h1>


<p>Blah. Blah blah blah blah, blah blah blah.</p>


<p><strong>Blah</strong> blah blah, blah bl-blah blah blah.</p>


<p><em>Blah</em> blah blah blah.</p>
</div>

There are lots of predefined filters, including:

* :plain doesn't parse the text at all, allowing you to put "." and
other Haml-significant characters at the beginning of a line
without escaping them with a backslash.
* :ruby interprets the text as Ruby code, and inserts all output
printed to stdout into the Haml document.
* :preserve preserves all whitespace in the text, even at the
beginning of lines.
* :erb parses the text with ERb, the engine used for RHTML.
* :sass parses the text with Sass, of course.
* :textile and :markdown run the respective text interpreters over
the text. :textile is only available if the RedCloth gem is
installed; :markdown is available if either RedCloth or BlueCloth
is installed.

The introduction of filters also means that the use of the "~" character
to denote a nested block of whitespace-sensitive text is now entirely
redundant. As such, we've deprecated it; it's still usable in 1.5, but a
warning will pop up, and it will be removed in the next version. The
:preserve filter should be used instead. The other use of the "~"
character, to preserve the whitespace in "<pre>" and "<textarea>" tags
output by functions, is still available.

Enjoy!
- Nathan

weepy

unread,
Mar 14, 2007, 8:11:48 AM3/14/07
to Haml
did the == operator for outputing ruby make it through ?


On Mar 14, 1:49 am, Nathan Weizenbaum <nex...@gmail.com> wrote:
> Hello, fellow Hamlites,
>
> Haml 1.5 has been released! Download the new version and give it a try:

> "./script/plugin installhttp://hamptoncatlin.com/svn/haml/tags/stable"


> for Rails, or just "gem install haml" if you want it on its own. It's
> absolutely worth the update. Along with plenty of bug fixes, version 1.5
> adds various usefull and snazzy features to Haml. But the biggest news
> in 1.5 isn't a new feature: it's an entirely new templating engine.
>
> You see, after using Haml for a while, one tends to get used to the idea
> that markup can, indeed /should/, be beautiful and concise. Other, less
> elegant markup languages begin to seem a little grating. While working
> on a stylesheet, one might think "I can right HTML in an elegant manner.
> Why can't I do the same thing with CSS?" Well, we thought that, too. So
> we came up with a solution: Syntactically Awesome StyleSheets, or "Sass."
>
> Sass is a templating engine for CSS that's bundled along with Haml 1.5.
> It allows you to write CSS using the same elegant whitespace-sensitive
> style used in Haml. It eliminates the redundancy formerly inherent in
> nesting CSS styles, using "namespace" styles such as font-family and
> font-weight, re-using the same value, and even writing out CSS rules.
> Just stick your ".sass" files in "public/stylesheets/sass", and
> corresponding ".css" files will be created whenever you need them to be.

> You can read all about it athttp://haml.hamptoncatlin.com/docs/sass/ref

Jean-Sébastien

unread,
Mar 13, 2007, 11:56:55 PM3/13/07
to Haml
Great! i gonna test it now!

On 14 mar, 02:49, Nathan Weizenbaum <nex...@gmail.com> wrote:
> Hello, fellow Hamlites,
>
> Haml 1.5 has been released! Download the new version and give it a try:

> "./script/plugin installhttp://hamptoncatlin.com/svn/haml/tags/stable"


> for Rails, or just "gem install haml" if you want it on its own. It's
> absolutely worth the update. Along with plenty of bug fixes, version 1.5
> adds various usefull and snazzy features to Haml. But the biggest news
> in 1.5 isn't a new feature: it's an entirely new templating engine.
>
> You see, after using Haml for a while, one tends to get used to the idea
> that markup can, indeed /should/, be beautiful and concise. Other, less
> elegant markup languages begin to seem a little grating. While working
> on a stylesheet, one might think "I can right HTML in an elegant manner.
> Why can't I do the same thing with CSS?" Well, we thought that, too. So
> we came up with a solution: Syntactically Awesome StyleSheets, or "Sass."
>
> Sass is a templating engine for CSS that's bundled along with Haml 1.5.
> It allows you to write CSS using the same elegant whitespace-sensitive
> style used in Haml. It eliminates the redundancy formerly inherent in
> nesting CSS styles, using "namespace" styles such as font-family and
> font-weight, re-using the same value, and even writing out CSS rules.
> Just stick your ".sass" files in "public/stylesheets/sass", and
> corresponding ".css" files will be created whenever you need them to be.

> You can read all about it athttp://haml.hamptoncatlin.com/docs/sass/ref

Russell Norris

unread,
Mar 14, 2007, 7:45:13 AM3/14/07
to ha...@googlegroups.com
Congrats on the 1.5. I'm running trunk so it's not so big for me but it's fun nonetheless. Big yay though about the Sass reference! I've been curious about it but couldn't see any documentation. Now I can check it out some. I'm always frustrated by typing out common margins and colors over and over. I hope Sass can lighten some of that load.

RS:

slai...@gmail.com

unread,
Mar 14, 2007, 10:31:22 AM3/14/07
to Haml
hi,
gret news!
thanks for the release, gonna test it.
Nicolas.

Nathan Weizenbaum

unread,
Mar 14, 2007, 11:13:31 AM3/14/07
to ha...@googlegroups.com
Indeed it did! I just forgot about it.

For those of you who don't know about it, there's another new operator
in 1.5: ==. It's a shortcut for outputting a Ruby string - you don't
need to use the quotes. For example, you could say

- foo = 3
== foo is #{foo}

Which would output

foo is 3

- Nathan

slai...@gmail.com

unread,
Mar 14, 2007, 11:01:51 AM3/14/07
to Haml
When will HAML be ISO-latin compatible ?

Thanks.
Nicolas.

Russell Norris

unread,
Mar 14, 2007, 7:42:47 PM3/14/07
to ha...@googlegroups.com
Ooh la la! I was just wanting something like that the other day. Thanks!

RSL

grandy

unread,
Mar 14, 2007, 8:12:20 PM3/14/07
to Haml
Does anyone know if there's anywhere to download the latest haml
plugin for RadRails?

-

Nathan Weizenbaum

unread,
Mar 14, 2007, 9:42:54 PM3/14/07
to ha...@googlegroups.com
Most likely when Ruby does, I'm sorry to say. Character encodings are
very tricky to deal with, and unless there's some library out there that
could function as more or less a drop-in replacement, it's not feasible
to implement, as we'd have to do it ourselves.

I'm interested in hearing what specific problems you're having, though,
in case there's some workaround you can use. Most strings in the
document are just passed straight on through Haml, so multibyte
characters shouldn't be an issue for those.

- Nathan

Nathan Weizenbaum

unread,
Mar 15, 2007, 10:28:18 AM3/15/07
to ha...@googlegroups.com
I believe that the author accidentally misplaced his own syntax
highlighting file, so it may not be available anywhere.

- Nathan

Nathan Weizenbaum

unread,
Mar 17, 2007, 12:46:12 AM3/17/07
to ha...@googlegroups.com
Apparently I gave the wrong URL for installing the stable Haml branch.
The real install command is:

"./script/plugin install http://svn.hamptoncatlin.com/haml/tags/stable"

Sorry about that!

- Nathan

weepy

unread,
Mar 25, 2007, 2:29:05 PM3/25/07
to Haml
is == still aroung - i just tried to use it in 1.5 and got :

(eval):29:in `compile': compile error
(eval):27: parse error, unexpected '='
haml_temp = = 5

from the line:

== 5

Nathan Weizenbaum

unread,
Mar 25, 2007, 3:11:54 PM3/25/07
to ha...@googlegroups.com
It should be in there... and it's working for me. Are you sure you're
using 1.5? Check the VERSION file in the plugin directory.

- Nathan

weepy

unread,
Mar 26, 2007, 6:12:54 AM3/26/07
to Haml
im on 1.6

Nathan Weizenbaum

unread,
Mar 26, 2007, 11:33:56 AM3/26/07
to ha...@googlegroups.com
That's really weird. All 1.6 revisions should have that functionality...
but what revision are you using?

- Nathan

weepy

unread,
Mar 27, 2007, 8:34:20 AM3/27/07
to Haml
it also doesnt work for me on the latest stable 1.5 build

Nathan Weizenbaum

unread,
Mar 27, 2007, 2:44:57 PM3/27/07
to ha...@googlegroups.com
That's very strange. Is anyone else having this problem? To test, just try to compile a template with "== 5". If it outputs "5", it's working... otherwise, it's not.

- Nathan

weepy

unread,
Mar 27, 2007, 4:36:54 PM3/27/07
to Haml
ok - so the behaviour is it works fine also long as theres nothing
before the == line and nothing after it

so :


%h1== Found #{@groupings.length} matches

DOESNT WORK

-------

%h1
== Found #{@groupings.length} matches

DOESNT WORK

-------


== Found #{@groupings.length} matches

- @groupings.each do |g|
= render :partial "short_profile", :locals => {:grouping => g}

DOESNT WORK

------

== Found #{@groupings.length} matches

DOES WORK


Nathan Weizenbaum

unread,
Mar 27, 2007, 9:29:42 PM3/27/07
to ha...@googlegroups.com
I'm still not able to reproduce this. Not, though, that == should only
work when it's on a separate line from a tag; "%h1==" is indeed an error.

- Nathan

Irfy

unread,
Mar 31, 2007, 9:09:57 PM3/31/07
to Haml
== 5 works for me, either alone or as part of a tag.

-- Irfy

Reply all
Reply to author
Forward
0 new messages