Hello, fellow Hamlites!

Today I wanted to showcase a new feature that's hot of the presses (or, 
rather, hard disk, I suppose). It's an addition to Sass' constant 
arithmetic capabilities. If you're not familiar with Sass, it's a 
Haml-like language for defining CSS using indentation and nested CSS 
rules - there's a whole Sneak Peak on it in the archives. It also allows 
you to define constants and perform arithmetic on them, like so:

!border_style= dotted
!main_color= #5588ee

#main
  :background-color= !main_color
  :border= "2px " + !border_style + " " + (!main_color - #555)
  p
    :border= "1px " + !border_style + " #0000aa"

This is a very powerful feature, but all those quotes and spaces and so 
forth is a little ugly. We don't like ugly, and one thing Haml has 
taught us is that we don't need to suffer ugliness for the sake of 
power. We can have both. So now we can... Sass will now automatically 
concatenate adjacent values when doing constant arithmetic. For example, 
the above could be written as:

!border_style= dotted
!main_color= #5588ee

#main
  :background-color= !main_color
  :border= 2px !border_style (!main_color - #555)
  p
    :border= 1px !border_style #0000aa

Much, much nicer. This will compile to:

#main {
  background-color: #5588ee;
  border: 2px dotted #003399; }
  p {
    border: 1px dotted #0000aa; }


Enjoy!

--~--~---------~--~----~------------~-------~--~----~
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