Now, Haml is a wonderful language, but it's not meant for everything. 
Obviously, stuff like CSS needs its own type of thing - that's why 
there's Sass. But there are even some situations where HTML might need 
more of a focus on the content and style than the structure. Then, a 
human-friendly markup language like Textile or Markdown might be better 
suited to the task than Haml. Unfortunately, these languages are most 
often useful within a structure-oriented HTML document, like the kind 
created by Haml. The only reasonable solution seems to be giving up and 
painstakingly writing out all those <em>, <hx>, and <p> tags in Haml.

Not anymore! Haml has a new feature: filters. You can now embed another 
parsing system right into your document. What was once

#script
  %h2 Hamlet
  %p
    Where wilt thou lead me?
    = succeed ';'
      %em speak
    I'll go no further.

  %h2 Ghost
  %p
    %strong Mark me.

  %h2 Hamlet
  %p I will.

  %h2 Ghost
  %p
    My hour is almost come,
    When I to sulphurous and tormenting flames
    Must render up myself.

  %h2 Hamlet
  %p Alas, poor ghost!

Now becomes

#script
  :markdown
    Hamlet
    ======

    Where wilt thou lead me? *speak*; I'll go no further.

    Ghost
    =====

    **Mark me.**

    Hamlet
    ======

    I will.

    Ghost
    =====

    My hour is almost come,
    When I to sulphurous and tormenting flames
    Must render up myself.

    Hamlet
    ======
  
    Alas, poor ghost!

Far nicer, and easier to read.

Haml comes predefined with several filters, and has a simple interface 
for defining your own. It comes with:

Markdown, Textile and Redcloth: Markdown and Textile are the human 
markup languages with those names, and Redcloth is a combination of the 
two. These are all only available if the Redcloth gem is installed, with 
the exception of Markdown, which is also available if BlueCloth is 
installed.

ERB: Uses ERB to parse the text.

Ruby: Runs the text through the Ruby interpreter, and outputs anything 
from the text printed to standard output.

Sass: Sass. Duh.

Plain: Doesn't parse the text at all, just outputs it straight out. This 
allows you to write text without worrying about stuff like "." or "%" 
causing Haml to try to parse the line.

In the future, you may be able to pass instance variables to the 
code-aware filters, like ERB and Ruby.

As usual, this feature is already implemented in trunk, so if you want 
to try it out, all you have to do is download. Enjoy!

- Nathan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to