Some of the introspection functions of Sass can be used to test whether a certain condition is true or not. Other introspection functions call a Sass function or return the type of a variable.
Read the Installing Sass for command line usage recipe of Chapter 1, Getting Started with Sass, to find out how to install Ruby Sass. You will also need Compass, so read the Installing Compass recipe of Chapter 1, Getting Started with Sass. You can edit the SCSS code in your favorite text editor. This recipe uses the same SCSS code as the one used for the Adding Custom Functions to Sass recipe of this chapter.
Here are the steps showing implementation of introspection functions:
Create a Sass template called cos.scss. The
cos.scss
file should contain the following lines of SCSS code:// scss-lint:disable PropertySpelling @function cosine($x) { @if function-exists(cos) { @return cos($x); } @else { @warn 'cos() function not found!'; ...