| Class | Sass::Tree::MixinDefNode |
| In: |
lib/sass/tree/mixin_def_node.rb
|
| Parent: | Node |
A dynamic node representing a mixin definition.
@see Sass::Tree
@param name [String] The mixin name @param args [Array<(Script::Node, Script::Node)>] The arguments for the mixin.
Each element is a tuple containing the variable for argument and the parse tree for the default value of the argument
# File lib/sass/tree/mixin_def_node.rb, line 11
11: def initialize(name, args)
12: @name = name
13: @args = args
14: super()
15: end
Loads the mixin into the environment.
@param environment [Sass::Environment] The lexical environment containing
variable and mixin values
# File lib/sass/tree/mixin_def_node.rb, line 42
42: def _perform(environment)
43: environment.set_mixin(@name, Sass::Mixin.new(@name, @args, environment, children))
44: []
45: end
Returns an error message if the given child node is invalid, and false otherwise.
{ExtendNode}s are valid within {MixinDefNode}s.
@param child [Tree::Node] A potential child node. @return [Boolean, String] Whether or not the child node is valid,
as well as the error message to display if it is invalid
# File lib/sass/tree/mixin_def_node.rb, line 55
55: def invalid_child?(child)
56: super unless child.is_a?(ExtendNode)
57: end
@see Node#to_src
# File lib/sass/tree/mixin_def_node.rb, line 20
20: def to_src(tabs, opts, fmt)
21: args =
22: if @args.empty?
23: ""
24: else
25: '(' + @args.map do |v, d|
26: if d
27: "#{v.to_sass(opts)}: #{d.to_sass(opts)}"
28: else
29: v.to_sass(opts)
30: end
31: end.join(", ") + ')'
32: end
33:
34: "#{' ' * tabs}#{fmt == :sass ? '=' : '@mixin '}#{dasherize(@name, opts)}#{args}" +
35: children_to_src(tabs, opts, fmt)
36: end