Documentation on guarded variables.

This commit is contained in:
Chris Eppstein 2010-03-17 08:59:06 -07:00
parent 41f1f30e0f
commit bc22684dc8
3 changed files with 35 additions and 0 deletions

View File

@ -90,6 +90,8 @@ body.reference
width: 100px
height: 20px
+border-radius(3px)
a.help
font-size: 75%
.tipsy

View File

@ -0,0 +1,30 @@
---
title: Working with Configurable Variables
classnames:
- tutorial
---
:markdown
Working with Configurable Variables
===================================
There are two ways of defining a variable in Sass. The first, most common, approach is
simple assignment. For example:
!my_constant = #fedcba
The second approach is called guarded assignment. In this case, the constant is only
set if it does not already have a value. For example:
!my_constant ||= #fedcba
Many compass modules use guarded assignment to allow you to set defaults for that module.
In order for these configurable variables to work correctly, you must set the variables
*before* you import the module. For example:
!blueprint_grid_columns = 12
@import blueprint/grid
Because of this, it is common to have one or more partials
that set the constants first and get imported before any other imports in your stylesheet(s).
This is commonly referred to as the "base" stylesheet and is usually named `_base.sass`.

View File

@ -11,6 +11,9 @@
%li
%a{:href => "/docs/best_practices/"}
Best practices
%ul
%li
%a{:href => "/docs/tutorials/configurable-variables/"} Configurable Variables
%li
%a{:href => "/docs/frameworks/"}
Working with plugins and frameworks