Skip to content

Instantly share code, notes, and snippets.

@Phize
Created July 2, 2014 11:08
Show Gist options
  • Save Phize/5835a5820d5dbfb45a58 to your computer and use it in GitHub Desktop.
Save Phize/5835a5820d5dbfb45a58 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.9)
// Compass (v1.0.0.alpha.20)
// ----
// This is an example to define private mixin(s)/function(s).
// by https://twitter.com/phize
// If this is not a bug, it is a bit useful
// although there are no way to export private mixin(s)/function(s).
// Dependency Injection: mixin injection
// http://sassmeister.com/gist/5122325c0c29889b91c3
// More simple way: @content injection
// http://sassmeister.com/gist/3686b8eb3462fef52013
// Polymorphic components:
// http://sassmeister.com/gist/1a10ec1c1556dfd3d6b5
// Type hinting:
// http://sassmeister.com/gist/28a2665ab30142df49b0
// Building decoupled components:
// https://sassmeister.com/gist/2ecf14567d1132c265e3
@mixin my-mixin() {
content: 'This is the global-mixin';
}
.class {
// A private variable.
$private-var: (
my-key: 'private'
);
// You may import private mixin(s)/function(s) by @import.
// @import 'default-private-mixins';
// @import 'default-private-functions';
// A private mixin: You may override global/default private mixin.
@mixin my-mixin() {
content: 'This is a private mixin';
}
// A private function: You may override global/default private function.
@function my-map-get($map, $key) {
@return map-get($map, 'my-' + $key);
}
// However, this doesn't work.
// @function map-get($map, $key) {
// @return map-get($map, 'my-' + $key);
// }
@include my-mixin();
map-value: my-map-get($private-var, 'key');
}
.another-class {
@include my-mixin();
}
.class {
content: 'This is a private mixin';
map-value: "private";
}
.another-class {
content: 'This is the global-mixin';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment