Skip to content

Latest commit

 

History

History
264 lines (162 loc) · 6.69 KB

File metadata and controls

264 lines (162 loc) · 6.69 KB

Meta-Programming Module

This built-in module is available from the URL sass:meta.

Table of Contents

Functions

call()

call($function, $args...)

This function is also available as a global function named call().

content-exists()

content-exists()

This function is also available as a global function named content-exists().

feature-exists()

feature-exists($feature)

This function is also available as a global function named feature-exists().

function-exists()

function-exists($name, $module: null)

This function is also available as a global function named function-exists().

  • If $name is not a string, throw an error.

  • If $module is null:

  • Otherwise, if $module isn't a string, throw an error.

  • Otherwise, let use be the @use rule in the current source file whose namespace is equal to $module. If no such rule exists, throw an error.

  • Return whether use's module contains a function named $name.

get-function()

get-function($name, $css: false, $module: null)

This function is also available as a global function named get-function().

  • If $name is not a string, throw an error.

  • If $module is null:

    • If $css is falsey:

    • Otherwise, return a function object that takes arguments ($args...). When this function is called:

      • If $args has any keyword arguments, throw an error.

      • Return a plain CSS function string with the name $name and the arguments $args.

  • Otherwise:

    • If $module isn't a string, throw an error.

    • If $css is truthy, throw an error.

    • Let use be the @use rule in the current source file whose namespace is equal to $module. If no such rule exists, throw an error.

    • Return use's module's function named $name, or throw an error if no such function exists.

global-variable-exists()

global-variable-exists($name, $module: null)

This function is also available as a global function named global-variable-exists().

  • If $name is not a string, throw an error.

  • If $module is null:

  • Otherwise, if $module isn't a string, throw an error.

  • Otherwise, let use be the @use rule in the current source file whose namespace is equal to $module. If no such rule exists, throw an error.

  • Return whether use's module contains a function named $name.

inspect()

inspect($value)

This function is also available as a global function named inspect().

keywords()

keywords($args)

This function is also available as a global function named keywords().

mixin-exists()

mixin-exists($name, $module: null)

This function is also available as a global function named mixin-exists().

  • If $name is not a string, throw an error.

  • If $module is null:

  • Otherwise, if $module isn't a string, throw an error.

  • Otherwise, let use be the @use rule in the current source file whose namespace is equal to $module. If no such rule exists, throw an error.

  • Return whether use's module contains a mixin named $name.

module-functions()

module-functions($module)

This function is also available as a global function named module-functions().

  • If $module is not a string, throw an error.

  • Let use be the @use rule in the current source file whose namespace is equal to $module. If no such rule exists, throw an error.

  • Return a map whose keys are the names of functions in use's module and whose values are the corresponding functions.

module-variables()

module-variables($module)

This function is also available as a global function named module-variables().

  • If $module is not a string, throw an error.

  • Let use be the @use rule in the current source file whose namespace is equal to $module. If no such rule exists, throw an error.

  • Return a map whose keys are the names (without $) of variables in use's module and whose values are the corresponding values.

type-of()

type-of($value)

This function is also available as a global function named type-of().

variable-exists()

variable-exists($name, $module: null)

This function is also available as a global function named variable-exists().

  • If $name is not a string, throw an error.

  • If $module is null:

  • Otherwise, if $module isn't a string, throw an error.

  • Otherwise, let use be the @use rule in the current source file whose namespace is equal to $module. If no such rule exists, throw an error.

  • Return whether use's module contains a mixin named $name.

Mixins

load-css()

load-css($url, $with: null)
  • If $url isn't a string, throw an error.

  • Let config be a configuration whose variable names and values are given by $with if $with isn't null, or the empty configuration otherwise.

  • Let module be the result of loading $url with config.

  • Let css be the result of resolving module's extensions.

    This means that, if a module loaded by load-css() shares some dependencies with the entrypoint module, those dependencies' CSS will be included twice.

  • Treat css as though it were the contents of the mixin.