Sha256: 2e3b625dbcd2c548ddd32259c8b842f23a180a6847cb741ff9fed2f31a744746

Contents?: true

Size: 1.03 KB

Versions: 17

Compression:

Stored size: 1.03 KB

Contents

require 'sass/tree/node'

module Sass::Tree
  class MixinNode < Node
    def initialize(name, args)
      @name = name
      @args = args
      super()
    end

    protected

    def _perform(environment)
      raise Sass::SyntaxError.new("Undefined mixin '#{@name}'.", @line) unless mixin = environment.mixin(@name)

      raise Sass::SyntaxError.new(<<END.gsub("\n", "")) if mixin.args.size < @args.size
Mixin #{@name} takes #{mixin.args.size} argument#{'s' if mixin.args.size != 1}
 but #{@args.size} #{@args.size == 1 ? 'was' : 'were'} passed.
END

      environment = mixin.args.zip(@args).
        inject(Sass::Environment.new(mixin.environment)) do |env, ((name, default), value)|
        env.set_local_var(name,
          if value
            value.perform(environment)
          elsif default
            default.perform(env)
          end)
        raise Sass::SyntaxError.new("Mixin #{@name} is missing parameter !#{name}.") unless env.var(name)
        env
      end
      mixin.tree.map {|c| c.perform(environment)}.flatten
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
gohanlonllc-haml-2.1.0.20080513000000 lib/sass/tree/mixin_node.rb
gohanlonllc-haml-2.1.0 lib/sass/tree/mixin_node.rb
haml-edge-2.1.12 lib/sass/tree/mixin_node.rb
haml-edge-2.1.10 lib/sass/tree/mixin_node.rb
haml-edge-2.1.11 lib/sass/tree/mixin_node.rb
haml-edge-2.1.16 lib/sass/tree/mixin_node.rb
haml-edge-2.1.17 lib/sass/tree/mixin_node.rb
haml-edge-2.1.18 lib/sass/tree/mixin_node.rb
haml-edge-2.1.20 lib/sass/tree/mixin_node.rb
haml-edge-2.1.15 lib/sass/tree/mixin_node.rb
haml-edge-2.1.21 lib/sass/tree/mixin_node.rb
haml-edge-2.1.13 lib/sass/tree/mixin_node.rb
haml-edge-2.1.14 lib/sass/tree/mixin_node.rb
haml-edge-2.1.19 lib/sass/tree/mixin_node.rb
haml-edge-2.1.9 lib/sass/tree/mixin_node.rb
haml-edge-2.1.8 lib/sass/tree/mixin_node.rb
haml-edge-2.1.7 lib/sass/tree/mixin_node.rb