Hello, fellow Hamlites,

While it's nice to be able to create standalone Sass templates, each 
website usually has at least three or four CSS files. Sass is wonderful 
for reducing the amount of repetition within a document, but what does 
it offer to minimize repeated code between several files? Is there a way 
to have all the CSS files share a few core rules or even (dare I 
suggest!) constant definitions?

Well, until now, there wasn't. But why would I have brought those issues 
up, in a Sneak Peek no less, if I weren't going to show a solution? 
Well, here's that solution: "@import". You may recognize that from CSS. 
Indeed, in Sass it works much the same way. It imports both the rules 
and the constants from another Sass file into the current file. So, for 
example, if you had a Sass file with a constant definitions and a small 
rule:

  // shared.sass
  !color = #1356e3

  a img
    :border-style none

You could import it into another file

  // main.sass
  @import shared

  #navbar
    :background-color = !color

And this would compile to

  a img {
    border-style: none; }

  #navbar {
    background-color: #1256e3; }

You may notice that I included just "shared", leaving off the ".sass" 
file extension. This is acceptable, as is explicitly including 
"shared.sass". If the file extension is removed and no file called 
"shared.sass" is found, the import directive will just compile to a 
literal CSS "@import shared.css". This makes it easy to transition from 
CSS to Sass without having to change the imports whenever you switch 
over a template.

As always, this feature is available right now in the Haml trunk, which 
can be installed using "./script/plugin install 
http://svn.hamptoncatlin.com/haml/trunk"; for Rails or "svn co 
svn://hamptoncatlin.com/haml/trunk" standalone. Give it a try.

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