A static node representing a mixin include. When in a static tree, the sole purpose is to wrap exceptions to add the mixin to the backtrace.
@see Sass::Tree
@see Node#cssize
# File lib/sass/tree/mixin_node.rb, line 25 25: def cssize(extends, parent = nil) 26: _cssize(extends, parent) # Pass on the parent even if it's not a MixinNode 27: end
@see Node#options=
# File lib/sass/tree/mixin_node.rb, line 11 11: def options=(opts) 12: super 13: @args.each {|a| a.context = :equals} if opts[:sass2] 14: end
@see Node#_cssize
# File lib/sass/tree/mixin_node.rb, line 50 50: def _cssize(extends, parent) 51: children.map do |c| 52: parent.check_child! c 53: c.cssize(extends, parent) 54: end.flatten 55: rescue Sass::SyntaxError => e 56: e.modify_backtrace(:mixin => @name, :filename => filename, :line => line) 57: e.add_backtrace(:filename => filename, :line => line) 58: raise e 59: end
Returns an error message if the given child node is invalid, and false otherwise.
{ExtendNode}s are valid within {MixinNode}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_node.rb, line 39 39: def invalid_child?(child) 40: super unless child.is_a?(ExtendNode) 41: end
Runs the mixin.
@param environment [Sass::Environment] The lexical environment containing
variable and mixin values
@raise [Sass::SyntaxError] if there is no mixin with the given name @raise [Sass::SyntaxError] if an incorrect number of arguments was passed @see Sass::Tree
# File lib/sass/tree/mixin_node.rb, line 68 68: def perform!(environment) 69: handle_include_loop!(environment) if environment.mixins_in_use.include?(@name) 70: 71: original_env = environment 72: original_env.push_frame(:filename => filename, :line => line) 73: original_env.prepare_frame(:mixin => @name) 74: raise Sass::SyntaxError.new("Undefined mixin '#{@name}'.") unless mixin = environment.mixin(@name) 75: 76: raise Sass::SyntaxError.new(Mixin #{@name} takes #{mixin.args.size} argument#{'s' if mixin.args.size != 1} but #{@args.size} #{@args.size == 1 ? 'was' : 'were'} passed..gsub("\n", "")) if mixin.args.size < @args.size 77: environment = mixin.args.zip(@args). 78: inject(Sass::Environment.new(mixin.environment)) do |env, ((var, default), value)| 79: env.set_local_var(var.name, 80: if value 81: value.perform(environment) 82: elsif default 83: val = default.perform(env) 84: if default.context == :equals && val.is_a?(Sass::Script::String) 85: val = Sass::Script::String.new(val.value) 86: end 87: val 88: end) 89: raise Sass::SyntaxError.new("Mixin #{@name} is missing parameter #{var.inspect}.") unless env.var(var.name) 90: env 91: end 92: 93: self.children = mixin.tree.map {|c| c.perform(environment)}.flatten 94: rescue Sass::SyntaxError => e 95: if original_env # Don't add backtrace info if this is an @include loop 96: e.modify_backtrace(:mixin => @name, :line => @line) 97: e.add_backtrace(:line => @line) 98: end 99: raise e 100: ensure 101: original_env.pop_frame if original_env 102: end
@see Node#to_src
# File lib/sass/tree/mixin_node.rb, line 44 44: def to_src(tabs, opts, fmt) 45: args = '(' + @args.map {|a| a.to_sass(opts)}.join(", ") + ')' unless @args.empty? 46: "#{' ' * tabs}#{fmt == :sass ? '+' : '@include '}#{dasherize(@name, opts)}#{args}#{semi fmt}\n" 47: end
# File lib/sass/tree/mixin_node.rb, line 109 109: def handle_include_loop!(environment) 110: msg = "An @include loop has been found:" 111: mixins = environment.stack.map {|s| s[:mixin]}.compact 112: if mixins.size == 2 && mixins[0] == mixins[1] 113: raise Sass::SyntaxError.new("#{msg} #{@name} includes itself") 114: end 115: 116: mixins << @name 117: msg << "\n" << Haml::Util.enum_cons(mixins, 2).map do |m1, m2| 118: " #{m1} includes #{m2}" 119: end.join("\n") 120: raise Sass::SyntaxError.new(msg) 121: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.