Class: Sass::Tree::MixinDefNode

Inherits:
Node
  • Object
show all
Defined in:
lib/sass/tree/mixin_def_node.rb

Overview

A dynamic node representing a mixin definition.

See Also:

Instance Attribute Summary

Attributes inherited from Node

#children, #filename, #has_children, #line, #options

Instance Method Summary collapse

Methods inherited from Node

#<<, #==, #_cssize, #_to_s, #balance, #check_child!, #children_to_src, #cssize, #cssize!, #dasherize, #do_extend, #each, #invalid_child?, #invisible?, #perform, #perform!, #perform_children, #render, #run_interp, #semi, #style, #to_s, #to_sass, #to_scss

Constructor Details

#initialize(name, args) ⇒ MixinDefNode

Returns a new instance of MixinDefNode.

Parameters:

  • name (String)

    The mixin name

  • 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



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.

Parameters:

  • environment (Sass::Environment)

    The lexical environment containing variable and mixin values



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

#to_src(tabs, opts, fmt) (protected)

See Also:



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