Created
June 17, 2014 00:16
-
-
Save pnts/2c67c0dbb42bb975dcc4 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains 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.3.8) | |
// Compass (v1.0.0.alpha.19) | |
// ---- | |
// Trying to figure out the best solution | |
// to instanciate a comma-separated empty list | |
// --- | |
// So far: `zip(())` | |
// --- | |
// Arglist version | |
// --- | |
// @pro: works in Sass 3.2.19 | |
// --- | |
// @con: defines `$args` but needs to be called with no arg | |
// @con: can't be used as a one-liner, without the function | |
// @con: returns an arglist | |
// --- | |
@function comma-list-arglist($args...) { | |
@return $args | |
} | |
// Join version | |
// --- | |
@function comma-list-join() { | |
@return join((), (), comma) | |
} | |
// Append version | |
// --- | |
// @con: add an empty value to list, increasing length from 1 | |
// --- | |
@function comma-list-append() { | |
@return append((), (), comma) | |
} | |
// Zip version | |
// --- | |
// @pro: is very short | |
// @pro: works in Sass 3.2.19 | |
// --- | |
@function comma-list-zip() { | |
@return zip(()) | |
} | |
// Comma version | |
// --- | |
// @con: doesn't work in Sass 3.2.19 | |
// @con: add an empty value to list, increasing length from 1 | |
// --- | |
@function comma-list-trailing-comma() { | |
@return (), | |
} | |
// Describe test | |
// --- | |
@mixin test($function) { | |
// Instanciate new list | |
$new-list: if($function == "regular-list", (), call($function)); | |
$list: $new-list; | |
// Fill | |
$list: append($list, alpha); | |
$list: append($list, beta); | |
$list: append($list, gamma); | |
// Dump data | |
method: unquote($function); | |
output: $list; | |
length: length($list); | |
type-when-empty: type-of($new-list); | |
type-when-full: type-of($list); | |
separator: list-separator($list); | |
/**/ | |
} | |
// Run test | |
// --- | |
regular-list { | |
@include test("regular-list"); | |
@include test("comma-list-zip"); | |
@include test("comma-list-join"); | |
@include test("comma-list-arglist"); | |
@include test("comma-list-append"); | |
@include test("comma-list-trailing-comma"); | |
} |
This file contains 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
regular-list { | |
method: regular-list; | |
output: alpha beta gamma; | |
length: 3; | |
type-when-empty: list; | |
type-when-full: list; | |
separator: space; | |
/**/ | |
method: comma-list-zip; | |
output: alpha, beta, gamma; | |
length: 3; | |
type-when-empty: list; | |
type-when-full: list; | |
separator: comma; | |
/**/ | |
method: comma-list-join; | |
output: alpha, beta, gamma; | |
length: 3; | |
type-when-empty: list; | |
type-when-full: list; | |
separator: comma; | |
/**/ | |
method: comma-list-arglist; | |
output: alpha, beta, gamma; | |
length: 3; | |
type-when-empty: arglist; | |
type-when-full: list; | |
separator: comma; | |
/**/ | |
method: comma-list-append; | |
output: alpha, beta, gamma; | |
length: 4; | |
type-when-empty: list; | |
type-when-full: list; | |
separator: comma; | |
/**/ | |
method: comma-list-trailing-comma; | |
output: alpha, beta, gamma; | |
length: 4; | |
type-when-empty: list; | |
type-when-full: list; | |
separator: comma; | |
/**/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment