Sass Introspection Functions

Sass 函数Sass Functions

Sass Introspection functions are rarely used for building stylesheets; they are generally used for debugging code.

The following table lists Sass's Introspection functions:

Function Description & Example
call(function, arguments...) Dynamic call of a function, i.e., calling the function with arguments as parameters and returning the result.
content-exists() Check whether the current mixin is passed a @content block.
feature-exists(feature) Check whether the current Sass implementation supports the feature.

Example:
feature-exists("at-error");
Result: true
function-exists(functionname) Detect whether the specified function exists

Example:
function-exists("nonsense")
Result: false
get-function(functionname, css: false) Return the specified function. If css is true, return the pure CSS function.
global-variable-exists(variablename) Detect whether a global variable is defined.

Example:
variable-exists(a)
Result: true
inspect(value) Return a string representation; value is a Sass expression.
mixin-exists(mixinname) Detect whether the specified mixin (mixinname) exists.

Example:
mixin-exists("important-text")
Result: true
type-of(value) Return the value type. The return value can be number, string, color, list, map, bool, null, function, arglist.

Example:
type-of(15px)
Result: number
type-of(#ff0000)
Result: color
unit(number) Return the unit (or compound unit) of the passed number.

Example:
unit(15px)
Result: px
unitless(number) Return a boolean value indicating whether the passed number has a unit.

Example:
unitless(15px)
Result: false
unitless(15)
Result: true
variable-exists(variablename) Determine whether a variable is in the current scope.

Example:
variable-exists(b)
Result: true

Sass 函数Sass Functions

Other Extensions