Accoutrement 2.1.1

Function Registration

Because Sass 3.5+ requires first-class functions, we provide tools for capturing functions and making them available to the Accoutrement map parser. This also provides the ability to alias functions as you like.

$functions (map)

scss
$functions: () !default;

We provide a single map to store & manage functions that you would like to use inside Accoutrement maps.

$functions: (
  'times': get-function('times'),
  'divide': get-function('divide'),
);

Functions can be registered multiple times, under any aliases, using our standard hashtag reference syntax:

$functions: (
  'times': get-function('times'),
  '*': '#times',
);

Since 0.1.0:

  • NEW: Supports the core map-refernece syntax, for creating function aliases

Map Properties

<alias>: (function)

Each alias key in the map should refer to a captured function

Used By

@function _a_get-function() [private]

@mixin register-function()

In addition to managing the $functions map directly, you can also register new functions on the fly:

  // the first value is the function name,
  // any additional values provide alias names for the same function
  @include register-function('rgba', 'alpha');

Functions only need to be registered if they will be used inside accoutrement maps. That includes core Sass functions.

Parameters & Output

$function: (string | function)

The function-name to be registered or a first-class function previously captured

$names...: (strings)

One or more alias names (strings) to use for map-access to the function

{CSS output} (code block)

{map} $functions - Functions are captured and added to the $functions map under any number of aliases

Example

scss
@include register-function('darken', 'shade');

/*! Registered Functions… */
@each $name, $value in $functions {
  /*! - #{$name}: #{$value} */
}
css compiled
@charset "UTF-8";
/*! Registered Functions… */
/*! - darken: get-function("darken") */
/*! - shade: #darken */

Requires

@function _a_registration() [private]

$functions (map)