Class Sass::Tree::MixinDefNode
In: lib/sass/tree/mixin_def_node.rb
Parent: Node

A dynamic node representing a mixin definition.

@see Sass::Tree

Methods

_perform   invalid_child?   new   to_src  

Public Class methods

@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

[Source]

    # 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

Protected Instance methods

Loads the mixin into the environment.

@param environment [Sass::Environment] The lexical environment containing

  variable and mixin values

[Source]

    # 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

[Source]

    # 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

[Source]

    # 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

[Validate]