Skip to content

Commit

Permalink
made sass mixin arguments more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
zspecza committed Aug 13, 2015
1 parent 5160170 commit 83abb02
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 39 deletions.
10 changes: 4 additions & 6 deletions lib/templates/system.template
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<% if (preprocessor.engine === 'sass') { %>
=<%= preprocessor.namespace %>system-block($mixin, $name)
#{$mixin + '(' + $name + ')'}
@content
<% } %>
<% _.each(mixins, function(name, mixin) { %>
<% if (preprocessor.engine === 'scss') { %>
@mixin <%= preprocessor.namespace + name %>($names...) {
Expand All @@ -13,7 +8,10 @@
<% } %>
<% if (preprocessor.engine === 'sass') { %>
=<%= preprocessor.namespace + name %>($names...)
+<%= preprocessor.namespace %>system-block(<%= name %>, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'<%= preprocessor.namespace + name %>(' + $all + ')'}
@content
<% } %>
<% if (preprocessor.engine === 'stylus') { %>
Expand Down
40 changes: 29 additions & 11 deletions test/fixtures/mixins/system-custom.sass
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
=system-block($mixin, $name)
#{$mixin + '(' + $name + ')'}
@content
=new($names...)
+system-block(new, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'new(' + $all + ')'}
@content
=part($names...)
+system-block(part, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'part(' + $all + ')'}
@content
=option($names...)
+system-block(option, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'option(' + $all + ')'}
@content
=state($names...)
+system-block(state, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'state(' + $all + ')'}
@content
=area($names...)
+system-block(area, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'area(' + $all + ')'}
@content
=tweak($names...)
+system-block(tweak, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'tweak(' + $all + ')'}
@content
=container($names...)
+system-block(container, $names)
@content
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'container(' + $all + ')'}
@content
40 changes: 29 additions & 11 deletions test/fixtures/mixins/system-namespaced.sass
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
=namespace-system-block($mixin, $name)
#{$mixin + '(' + $name + ')'}
@content
=namespace-component($names...)
+namespace-system-block(component, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'namespace-component(' + $all + ')'}
@content
=namespace-has($names...)
+namespace-system-block(has, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'namespace-has(' + $all + ')'}
@content
=namespace-when($names...)
+namespace-system-block(when, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'namespace-when(' + $all + ')'}
@content
=namespace-is($names...)
+namespace-system-block(is, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'namespace-is(' + $all + ')'}
@content
=namespace-inside($names...)
+namespace-system-block(inside, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'namespace-inside(' + $all + ')'}
@content
=namespace-util($names...)
+namespace-system-block(util, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'namespace-util(' + $all + ')'}
@content
=namespace-container($names...)
+namespace-system-block(container, $names)
@content
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'namespace-container(' + $all + ')'}
@content
40 changes: 29 additions & 11 deletions test/fixtures/mixins/system.sass
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
=system-block($mixin, $name)
#{$mixin + '(' + $name + ')'}
@content
=component($names...)
+system-block(component, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'component(' + $all + ')'}
@content
=has($names...)
+system-block(has, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'has(' + $all + ')'}
@content
=when($names...)
+system-block(when, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'when(' + $all + ')'}
@content
=is($names...)
+system-block(is, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'is(' + $all + ')'}
@content
=inside($names...)
+system-block(inside, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'inside(' + $all + ')'}
@content
=util($names...)
+system-block(util, $names)
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'util(' + $all + ')'}
@content
=container($names...)
+system-block(container, $names)
@content
$all: ()
@each $name in $names
$all: append($all, unquote($name), comma)
#{'container(' + $all + ')'}
@content

0 comments on commit 83abb02

Please sign in to comment.