A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://sass-lang.com/documentation/values/functions below:

Sass: Function Values

Compatibility (Argument Type):

Dart Sass

LibSass
since 3.5.0

Ruby Sass
since 3.5.0

In older versions of LibSass and Ruby Sass, the call() function took a string representing a function’s name. This was changed to take a function value instead in preparation for a new module system where functions are no longer global and so a given name may not always refer to the same function.

Passing a string to call() still works in all implementations, but it’s deprecated and will be disallowed in future versions.

Functions can be values too! You can’t directly write a function as a value, but you can pass a function’s name to the meta.get-function() function to get it as a value. Once you have a function value, you can pass it to the meta.call() function to call it. This is useful for writing higher-order functions that call other functions.

Playground SCSS Syntax
@use "sass:list";
@use "sass:meta";
@use "sass:string";



@function remove-where($list, $condition) {
  $new-list: ();
  $separator: list.separator($list);
  @each $element in $list {
    @if not meta.call($condition, $element) {
      $new-list: list.append($new-list, $element, $separator: $separator);
    }
  }
  @return $new-list;
}

$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif;

.content {
  @function contains-helvetica($string) {
    @return string.index($string, "Helvetica");
  }
  font-family: remove-where($fonts, meta.get-function("contains-helvetica"));
}
Playground Sass Syntax
@use "sass:list"
@use "sass:meta"
@use "sass:string"



@function remove-where($list, $condition)
  $new-list: ()
  $separator: list.separator($list)
  @each $element in $list
    @if not meta.call($condition, $element)
      $new-list: list.append($new-list, $element, $separator: $separator)


  @return $new-list


$fonts: Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif

.content
  @function contains-helvetica($string)
    @return string.index($string, "Helvetica")

  font-family: remove-where($fonts, meta.get-function("contains-helvetica"))

CSS Output
.content {
  font-family: Tahoma, Geneva, Arial, sans-serif;
}























RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4