Skip to content

Instantly share code, notes, and snippets.

@pnts
Created June 17, 2014 00:16
Show Gist options
  • Save pnts/2c67c0dbb42bb975dcc4 to your computer and use it in GitHub Desktop.
Save pnts/2c67c0dbb42bb975dcc4 to your computer and use it in GitHub Desktop.

Revisions

  1. pnts created this gist Jun 17, 2014.
    87 changes: 87 additions & 0 deletions SassMeister-input.scss
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,87 @@
    // ----
    // 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");
    }
    44 changes: 44 additions & 0 deletions SassMeister-output.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    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;
    /**/
    }