Skip to content

Instantly share code, notes, and snippets.

@KittyGiraudel
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save KittyGiraudel/7defdda692bfd2f2e6a9 to your computer and use it in GitHub Desktop.

Select an option

Save KittyGiraudel/7defdda692bfd2f2e6a9 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.13)
// Compass (v1.0.3)
// ----
// Global map hosting function aliases
// @type Map
// @prop {String} key - Alias name
// @prop {String} value - Mapped function
$function-aliases: () !global;
// Mixin to add aliases to alias map
// @param {String} $function - Function to alias
// @param {List} $aliases - List of aliases to add
// @requires $function-aliases
// @output Nothing
@mixin add-alias($function, $aliases...) {
@each $alias in $aliases {
$function-aliases: map-merge($function-aliases, ($alias: $function)) !global;
}
}
// Add aliases to the `round` function to work around typos
@include add-alias('round', 'roudn', 'ruond');
// Proxy function
// @param {String} $function - Function to call
// @param {Arglist} $arguments - Arguments to pass to `$function`
// @requires $function-aliases
// @return Result of `$function` with `$arguments`
@function proxy($function, $arguments...) {
@if map-has-key($function-aliases, $function) {
@return call(map-get($function-aliases, $function), $arguments...);
}
@return call($function, $arguments...);
}
sass {
test: proxy('roudn', 13.37);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment