Skip to content

Instantly share code, notes, and snippets.

@wintercounter
Created December 30, 2014 01:22
Show Gist options
  • Save wintercounter/ce49e2d4b5d937845d19 to your computer and use it in GitHub Desktop.
Save wintercounter/ce49e2d4b5d937845d19 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.1.0-beta)
// ----
@function str-explode($string, $delimiter: '') {
$result: ();
$length: str-length($string);
@if str-length($delimiter) == 0 {
@for $i from 1 through $length {
$result: append($result, str-slice($string, $i, $i));
}
@return $result;
}
$running: true;
$remaining: $string;
@while $running {
$index: str-index($remaining, $delimiter);
@if $index {
$slice: str-slice($remaining, 1, $index - 1);
$result: append($result, $slice);
$remaining: str-slice($remaining, $index + str-length($delimiter));
}
@else {
$running: false;
}
}
@return append($result, $remaining);
}
@function _config-get($original){
$keys: str-explode($original, '.');
$result: $config;
@each $key in $keys {
@if map-has-key($result, $key) {
$result: map-get($result, $key);
}
@else {
@return $original;
}
}
@return $result;
}
@function _config-set($original, $value){
$keys: str-explode($original, '.');
$keysNum: length($keys);
$iterator: 1;
$tempConfig: $config;
$lastKey: null;
$pieces: ();
$result: ();
@each $key in $keys {
// No such key yet? Then create it
@if type-of($tempConfig) != map or map-has-key($tempConfig, $key) == false {
@if type-of($tempConfig) != map {
$tempConfig: ();
}
$tempConfig: map-merge($tempConfig, (
$key: ()
));
}
@else {
$v: map-get($tempConfig, $key);
@if type-of($v) != map {
$v: ();
}
$tempConfig: $v;
}
// Store pieces
$pieces: map-merge($pieces, ($iterator: $tempConfig));
$iterator: $iterator + 1;
}
// Merge back
$i: $keysNum;
@while $i > 0 {
$key: nth($keys, $i);
$piece: map-get($pieces, $i - 1);
@if $keysNum == 1 {
$piece: ();
}
@if $i == $keysNum {
@if type-of($value) == map and type-of(map-get($pieces, $i)) == map {
$result: map-merge($piece, ($key: map-merge(map-get($pieces, $i), $value)));
}
@else if type-of($piece) == map and map-has-key($piece, $key) {
$result: map-merge($piece, ($key: $value));
}
@else {
$result: ($key: $value);
}
}
@else if $i > 1 {
$result: map-merge($piece, ($key: $result));
}
$i: $i - 1;
@if $i == 0 {
@if $keysNum == 1 {
$config: map-merge($config, $result);
}
@else{
$config: map-merge($config, ($key: $result));
}
}
}
@return $config;
@return _config($original);
}
@function _config($key, $value: 'it-is-a-getter'){
@if $value == 'it-is-a-getter' {
@return _config-get($key);
}
@else {
@return _config-set($key, $value);
}
}
$config: (eminem: ('k': k, masod: pilot));
//$x: _config('eminem.hurka.szar', 'nem szar');
//@warn config('eminem.hurka.szar');
$_: _config('_grid', (
columnPrefix: C, /* Prefix for column class names */
columnIndentLeftPrefix: L, /* Prefix for column class names */
columnIndentRightPrefix: R, /* Prefix for column class names */
columnCount: 48, /* Total count of columns in a row; Ideal: 12, 16, 24*/
gutter: 30px, /* Gutter between columns */
rowWidth: 100%, /* The default site width */
breakPoint: 1260px, /* Below this width first child rows in the site_wrapper will get gutter padding from left and right */
gutterList: top right bottom left /* Helper list for gutter classes and positions (No need to edit) */
));
body{
//content: _config('eminem.k.inner.belsos', (belsos: laci));
//content: _config('eminem', (szula: emi));
content: _config('_grid.columnPrefix');
}
body {
content: C; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment