Last active
August 29, 2015 14:20
-
-
Save KittyGiraudel/b9465f46031da717cc60 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
// _________ .___ | |
// \_ ___ \ ____ __| _/____ | |
// / \ \/ / _ \ / __ |/ __ \ | |
// \ \___( <_> ) /_/ \ ___/ | |
// \______ /\____/\____ |\___ > | |
// \/ \/ \/ | |
/// Apply $function on each item from $list | |
/// using current item as first argument | |
/// and $args as optional extra arguments | |
/// @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 map($list, $function, $args...) { | |
@for $i from 1 through length($list) { | |
$list: set-nth($list, $i, call($function, nth($list, $i), $args...)); | |
} | |
@return $list; | |
} | |
// ________ | |
// \______ \ ____ _____ ____ | |
// | | \_/ __ \ / \ / _ \ | |
// | ` \ ___/| Y Y ( <_> ) | |
// /_______ /\___ >__|_| /\____/ | |
// \/ \/ \/ | |
@function double($value) { | |
@return $value * 2; | |
} | |
@function multiply($a, $b) { | |
@return $a * $b; | |
} | |
.foo { | |
$list: (1, 2, 3, 4, 5); | |
content: map($list, 'double'); | |
content: map($list, 'multiply', 5); | |
} | |
.bar { | |
$list: ('a', 'b', 'c', 'd', 'e'); | |
content: map($list, 'to-upper-case'); | |
content: map($list, 'unquote'); | |
} |
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, 6, 8, 10; | |
content: 5, 10, 15, 20, 25; | |
} | |
.bar { | |
content: 'A', 'B', 'C', 'D', 'E'; | |
content: a, b, c, d, e; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment