Class: Sass::Tree::MixinDefNode
- Defined in:
- lib/sass/tree/mixin_def_node.rb
Overview
A dynamic node representing a mixin definition.
Constant Summary
Constants inherited from Node
Instance Attribute Summary
Attributes inherited from Node
#children, #filename, #has_children, #line, #options
Instance Method Summary collapse
-
#_perform(environment)
protected
Loads the mixin into the environment.
-
#initialize(name, args) ⇒ MixinDefNode
constructor
A new instance of MixinDefNode.
-
#invalid_child?(child) ⇒ Boolean, String
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
#<<, #==, #_around_dump, #_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
#initialize(name, args) ⇒ MixinDefNode
Returns a new instance of MixinDefNode.
11 12 13 14 15 |
# File '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 'lib/sass/tree/mixin_def_node.rb', line 42
def _perform(environment)
environment.set_mixin(@name, Sass::Mixin.new(@name, @args, environment, children))
[]
end
|
#invalid_child?(child) ⇒ Boolean, String (protected)
Returns an error message if the given child node is invalid, and false otherwise.
ExtendNodes are valid within Sass::Tree::MixinDefNodes.
55 56 57 |
# File '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 '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
|