compass/doc-src/content/tutorials/configurable-variables.haml

32 lines
1.1 KiB
Plaintext
Raw Normal View History

2010-03-17 15:59:06 +00:00
---
title: Working with Configurable Variables
2010-04-24 17:03:34 +00:00
layout: tutorial
2010-03-17 15:59:06 +00:00
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:
2010-04-24 17:03:34 +00:00
$my-constant : #fedcba
2010-03-17 15:59:06 +00:00
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:
2010-04-24 17:03:34 +00:00
$my-constant : #fedcba !default
2010-03-17 15:59:06 +00:00
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:
2010-04-24 17:03:34 +00:00
$blueprint-grid-columns = 12
@import "blueprint/grid"
2010-03-17 15:59:06 +00:00
Because of this, it is common to have one or more partials
2010-04-24 17:03:34 +00:00
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.scss` or `_base.sass`.