Created
March 10, 2014 14:37
-
-
Save acdlite/9466131 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.3) | |
// Compass (v1.0.0.alpha.18) | |
// Sassy Maps (v0.3.2) | |
// ---- | |
@import "sassy-maps"; | |
$__namespaces: (); | |
@mixin create-namespace($name) { | |
$__namespaces: map-set($__namespaces, $name, ()); | |
} | |
@function namespace-set($name, $args...) { | |
$length: length($args); | |
$namespace: map-get($__namespaces, $name); | |
@if length($args) == 1 { | |
@if type-of(nth($args, 1)) == map { | |
$namespace: map-merge($namespace, nth($args, 1)); | |
} @else { | |
@warn "Must pass either a map or 2 or more values." | |
} | |
} | |
@else { | |
$keys: nth($args, 1); | |
@if length($keys) == 1 { | |
$namespace: map-set($namespace, $args...); | |
} @else { | |
$namespace: map-set-deep($namespace, $args...); | |
} | |
} | |
$__namespaces: map-merge($__namespaces, ($name: $namespace)); | |
@return $namespace; | |
} | |
@function namespace-get($name, $args...) { | |
$length: length($args); | |
$namespace: map-get($__namespaces, $name); | |
@if $length > 0 { | |
$keys: nth($args, 1); | |
@if length($keys) == 1 { | |
@return map-get($namespace, $args...); | |
} @else { | |
@return map-get-deep($namespace, $args...); | |
} | |
} @else { | |
@return $namespace; | |
} | |
} | |
@mixin namespace-set($name, $args...) { | |
$namespace: namespace-set($name, $args...); | |
} | |
/// | |
@include create-namespace(color); | |
@function color($key) { | |
@return namespace-get(color, $key); | |
} | |
output { | |
@include namespace-set(color, primary, red); | |
foo: namespace-get(color, primary); | |
bar: color(primary); | |
} |
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
output { | |
foo: red; | |
bar: red; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment