Skip to content

Instantly share code, notes, and snippets.

@roryashfordbentley
Created September 29, 2014 12:49
Show Gist options
  • Save roryashfordbentley/0b3faffcf68f913a4c97 to your computer and use it in GitHub Desktop.
Save roryashfordbentley/0b3faffcf68f913a4c97 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v2.0.0)
// ----
/**
* libsass list manipulation problem
* I am using the following code as a crude example.
* the real world application I am trying to achieve
* is providing grid system setup via a single $args array.
*/
/**
* Sass-lib-maps polyfill for sass 3.3+ list map
* support in libsass 2.0.0
*/
@import "sass-list-maps";
/**
* Basic multidimensional array, not the most practical
* real world example but it does a good job of
* illustrating the problem
*/
$items: (
item1(
option 10px
),
item2(
option 20px
),
item3(
option 30px
)
);
/**
* Trying to use sass @each to walk through the above
* array '$items'. As you can see from the output the
* map-get function returns a null value.
*/
.rule{
@each $item in $items{
width: map-get($item,option);
}
}
/**
* Lets make sure that the map-get function works
* as expected outside the @each loop.
*
*/
$items2: (
option1 10px,
option2 20px
);
.rule2{
width: map-get($items2,option1);
height: map-get($items2,option2);
}
/**
* Real world array(list) I would like to use.
* As the first children of the list are dynamic
* I need to be able to walk through with @each.
*/
/**
$grid_args:(
default(
options (
columns 6,
suffix null,
breakpoint null,
gutter 30px
)
),
medium(
options (
columns 12,
suffix 'm',
breakpoint $m,
gutter 30px
)
),
large(
options (
columns 12,
suffix 'l',
breakpoint $l,
gutter 30px
)
)
);
*/
/**
* libsass list manipulation problem
* I am using the following code as a crude example.
* the real world application I am trying to achieve
* is providing grid system setup via a single $args array.
*/
/**
* Sass-lib-maps polyfill for sass 3.3+ list map
* support in libsass 2.0.0
*/
/**
* Basic multidimensional array, not the most practical
* real world example but it does a good job of
* illustrating the problem
*/
/**
* Trying to use sass @each to walk through the above
* array '$items'. As you can see from the output the
* map-get function returns a null value.
*/
.rule {
width: null;
width: null;
width: null; }
/**
* Lets make sure that the map-get function works
* as expected outside the @each loop.
*
*/
.rule2 {
width: 10px;
height: 20px; }
/**
* Real world array(list) I would like to use.
* As the first children of the list are dynamic
* I need to be able to walk through with @each.
*/
/**
$grid_args:(
default(
options (
columns 6,
suffix null,
breakpoint null,
gutter 30px
)
),
medium(
options (
columns 12,
suffix 'm',
breakpoint $m,
gutter 30px
)
),
large(
options (
columns 12,
suffix 'l',
breakpoint $l,
gutter 30px
)
)
);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment