Class: Sass::Tree::MixinDefNode
Overview
A dynamic node representing a mixin definition.
Instance Method Summary
- - _perform(environment) protected Loads the mixin into the environment.
- - (MixinDefNode) initialize(name, args) constructor A new instance of MixinDefNode.
- - (Boolean, String) invalid_child?(child) protected Returns an error message if the given child node is invalid, and false otherwise.
- - to_src(tabs, opts, fmt) protected
Methods inherited from Node
#<<, #==, #_cssize, #_to_s, #balance, #check_child!, #children_to_src, #cssize, #cssize!, #dasherize, #do_extend, #each, #invisible?, #perform, #perform!, #perform_children, #run_interp, #selector_to_sass, #selector_to_scss, #selector_to_src, #semi, #style, #to_s, #to_sass, #to_scss
Constructor Details
- (MixinDefNode) initialize(name, args)
A new instance of MixinDefNode
11 12 13 14 15 |
# File '/var/www/sass-pages/.haml/lib/sass/tree/mixin_def_node.rb', line 11
def initialize(name, args)
@name = name
@args = args
super()
end
|
Instance Method Details
- _perform(environment) (protected)
Loads the mixin into the environment.
42 43 44 45 |
# File '/var/www/sass-pages/.haml/lib/sass/tree/mixin_def_node.rb', line 42
def _perform(environment)
environment.set_mixin(@name, Sass::Mixin.new(@name, @args, environment, children))
[]
end
|
- (Boolean, String) invalid_child?(child) (protected)
Returns an error message if the given child node is invalid, and false otherwise.
ExtendNodes are valid within MixinDefNodes.
55 56 57 |
# File '/var/www/sass-pages/.haml/lib/sass/tree/mixin_def_node.rb', line 55
def invalid_child?(child)
super unless child.is_a?(ExtendNode)
end
|
- to_src(tabs, opts, fmt) (protected)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File '/var/www/sass-pages/.haml/lib/sass/tree/mixin_def_node.rb', line 20
def to_src(tabs, opts, fmt)
args =
if @args.empty?
""
else
'(' + @args.map do |v, d|
if d
"#{v.to_sass(opts)}: #{d.to_sass(opts)}"
else
v.to_sass(opts)
end
end.join(", ") + ')'
end
"#{' ' * tabs}#{fmt == :sass ? '=' : '@mixin '}#{dasherize(@name, opts)}#{args}" +
children_to_src(tabs, opts, fmt)
end
|