Created
May 6, 2015 10:24
-
-
Save KittyGiraudel/f2a9a0d4365d309a0be9 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.4.13) | |
// Compass (v1.0.3) | |
// ---- | |
// _________ .___ | |
// \_ ___ \ ____ __| _/____ | |
// / \ \/ / _ \ / __ |/ __ \ | |
// \ \___( <_> ) /_/ \ ___/ | |
// \______ /\____/\____ |\___ > | |
// \/ \/ \/ | |
/// Filter $list only keeping item for which $function call | |
/// with $args as optional extra arguments returns a truthy value. | |
/// @author Hugo Giraudel | |
/// @param {List} $list - List to run function on | |
/// @param {String} $function - Name of function to run | |
/// @param {Arglist} $args - Optional extra arguments | |
/// @return {List} | |
@function filter($list, $function, $args...) { | |
$u-list: (); | |
@each $item in $list { | |
@if call($function, $item, $args...) { | |
$u-list: append($u-list, $item); | |
} | |
} | |
@return $u-list; | |
} | |
// ________ | |
// \______ \ ____ _____ ____ | |
// | | \_/ __ \ / \ / _ \ | |
// | ` \ ___/| Y Y ( <_> ) | |
// /_______ /\___ >__|_| /\____/ | |
// \/ \/ \/ | |
@function is-even($value) { | |
@return $value % 2 == 0; | |
} | |
.foo { | |
$list: (1, 2, 3, 4, 5); | |
content: filter($list, 'is-even'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.foo { | |
content: 2 4; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment