Sass module provides more advanced meta functions
Install the package:
npm i meta-sass-module
Use the package like any other Sass module:
@use "meta-sass-module"
Depending on your setup, you may need to configure node_modules
as include path:
const sass = require("sass");
sass.render({
file: scss_filename,
includePaths: ["node_modules"],
});
# | Name | Description |
---|---|---|
1 |
Applymeta-sass-module.apply($mixin, $args...)
|
Mixins can also be values! You can’t directly write a mixin as a value, but you can pass a mixin’s name to the meta-sass-module.get-mixin() function to get it as a value. Once you have a mixin value, you can pass it to the meta-sass-module.apply() mixin to call it. This is for libraries to be extensible in complex and powerful ways. |
2 |
Load CSSmeta-sass-module.load-css($url, $with: null)
|
Loads the module at $url and includes its CSS as though it were written as the contents of this mixin. |
# | Name | Description |
---|---|---|
1 |
Accepts Contentmeta-sass-module.accepts-content($mixin)
|
Returns whether the given mixin value can accept a @content block. |
2 |
Calculation Argumentsmeta-sass-module.calc-args($calc)
|
Returns the arguments for the given calculation. |
3 |
Calculation Namemeta-sass-module.calc-name($calc)
|
Returns the name for the given calculation. |
4 |
Callmeta-sass-module.call($function, $args...)
|
Invokes $function with $args and returns the result. |
5 |
Content Existsmeta-sass-module.content-exists()
|
Returns whether the current mixin was passed a block. |
6 |
Feature Existsmeta-sass-module.feature-exists($feature)
|
Returns whether the current Sass implementation supports $feature . |
7 |
Function Existsmeta-sass-module.function-exists($name, $module: null)
|
Returns whether a function named $name is defined, either as a built-in function or a user-defined function. |
8 |
Get Functionmeta-sass-module.get-function($name, $css: false, $module: null)
|
Returns the function value named $name . |
9 |
Get Mixinmeta-sass-module.get-mixin($name, $module: null)
|
Returns the mixin value named $name . |
10 |
Global Variable Existsmeta-sass-module.global-variable-exists($name, $module: null)
|
Returns whether a global variable named $name (without the $) exists. |
11 |
Inspectmeta-sass-module.inspect($value)s
|
Returns a string representation of $value . |
12 |
Keywordsmeta-sass-module.keywords($args)
|
Returns the keywords passed to a mixin or function that takes arbitrary arguments. The $args argument must be an argument list. |
13 |
Mixin Existsmeta-sass-module.mixin-exists($name, $module: null)
|
Returns whether a mixin named $name exists. |
14 |
Module Functionsmeta-sass-module.module-functions($module)
|
Returns all the functions defined in a module, as a map from function names to function values. |
15 |
Module Mixinsmeta-sass-module.module-mixins($module)
|
Returns all the mixins defined in a module, as a map from mixin names to mixin values. |
16 |
Module Variablesmeta-sass-module.module-variables($module)
|
Returns all the variables defined in a module, as a map from variable names (without $) to the values of those variables. |
17 |
Type ofmeta-sass-module.type-of($value)
|
Returns the type of $value . This can return the following values: number, string, color, list, map, calculation, bool, null, function, arglist |
18 |
Variable Existsmeta-sass-module.variable-exists($name)
|
Returns whether a variable named $name (without the $) exists in the current scope. |