30 lines
1.0 KiB
Plaintext
30 lines
1.0 KiB
Plaintext
---
|
|
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`. |