class Sass::Tree::PropNode

@see Sass::Tree
A static node reprenting a CSS property.

def ==(other)

Returns:
  • (Boolean) - Whether or not this node and the other object

Parameters:
  • other (Object) -- The object to compare with
def ==(other)
  self.class == other.class && name == other.name && value == other.value && super
end

def _cssize(extends, parent)

Raises:
  • (Sass::SyntaxError) - if the property uses invalid syntax

Parameters:
  • parent (PropNode, nil) -- The parent node of this node,
  • extends (Haml::Util::SubsetMap{Selector::Simple => Selector::Sequence}) --
def _cssize(extends, parent)
  node = super
  result = node.children.dup
  if !node.resolved_value.empty? || node.children.empty?
    node.send(:check!)
    result.unshift(node)
  end
  result
end

def _to_s(tabs)

Returns:
  • (String) - The resulting CSS

Parameters:
  • tabs (Fixnum) -- The level of indentation for the CSS
def _to_s(tabs)
  to_return = '  ' * (tabs - 1 + self.tabs) + resolved_name + ":" +
    (style == :compressed ? '' : ' ') + resolved_value + (style == :compressed ? "" : ";")
end

def check!

def check!
  if @options[:property_syntax] == :old && @prop_syntax == :new
    raise Sass::SyntaxError.new("Illegal property syntax: can't use new syntax when :property_syntax => :old is set.")
  elsif @options[:property_syntax] == :new && @prop_syntax == :old
    raise Sass::SyntaxError.new("Illegal property syntax: can't use old syntax when :property_syntax => :new is set.")
  elsif resolved_value.empty?
    raise Sass::SyntaxError.new("Invalid property: #{declaration.dump} (no value)." +
      pseudo_class_selector_message)
  end
end

def cssize!(extends, parent)

Parameters:
  • parent (PropNode, nil) -- The parent node of this node,
  • extends (Haml::Util::SubsetMap{Selector::Simple => Selector::Sequence}) --
def cssize!(extends, parent)
  self.resolved_name = "#{parent.resolved_name}-#{resolved_name}" if parent
  self.tabs = parent.tabs + (parent.resolved_value.empty? ? 0 : 1) if parent && style == :nested
  super
end

def declaration(tabs = 0, opts = {:old => @prop_syntax == :old}, fmt = :sass)

def declaration(tabs = 0, opts = {:old => @prop_syntax == :old}, fmt = :sass)
  name = self.name.map {|n| n.is_a?(String) ? n : "\#{#{n.to_sass(opts)}}"}.join
  if name[0] == ?:
    raise Sass::SyntaxError.new("The \":#{name}: #{self.class.val_to_sass(value, opts)}\" hack is not allowed in the Sass indented syntax")
  end
  old = opts[:old] && fmt == :sass
  initial = old ? ':' : ''
  mid = old ? '' : ':'
  "#{'  ' * tabs}#{initial}#{name}#{mid} #{self.class.val_to_sass(value, opts)}".rstrip
end

def initialize(name, value, prop_syntax)

Parameters:
  • prop_syntax (Symbol) -- `:new` if this property uses `a: b`-style syntax,
  • value (Sass::Script::Node) -- See \{#value}
  • name (Array) -- See \{#name}
def initialize(name, value, prop_syntax)
  @name = Haml::Util.strip_string_array(
    Haml::Util.merge_adjacent_strings(name))
  @value = value
  @tabs = 0
  @prop_syntax = prop_syntax
  super()
end

def invalid_child?(child)

Returns:
  • (String) - An error message if the child is invalid, or nil otherwise

Parameters:
  • child (Tree::Node) -- A potential child node
def invalid_child?(child)
  if !child.is_a?(PropNode) && !child.is_a?(CommentNode)
    "Illegal nesting: Only properties may be nested beneath properties."
  end
end

def perform!(environment)

Parameters:
  • environment (Sass::Environment) -- The lexical environment containing
def perform!(environment)
  @resolved_name = run_interp(@name, environment)
  val = @value.perform(environment)
  @resolved_value =
    if @value.context == :equals && val.is_a?(Sass::Script::String)
      val.value
    else
      val.to_s
    end
  super
end

def pseudo_class_selector_message

Returns:
  • (String) - The message
def pseudo_class_selector_message
  return "" if @prop_syntax == :new || !value.is_a?(Sass::Script::String) || !value.value.empty?
  "\nIf #{declaration.dump} should be a selector, use \"\\#{declaration}\" instead."
end

def to_src(tabs, opts, fmt)

Other tags:
    See: Node#to_src -
def to_src(tabs, opts, fmt)
  res = declaration(tabs, opts, fmt)
  return res + "#{semi fmt}\n" if children.empty?
  res + children_to_src(tabs, opts, fmt).rstrip + semi(fmt) + "\n"
end

def val_to_sass(value, opts)

Other tags:
    Private: -
def val_to_sass(value, opts)
  val_to_sass_comma(value, opts).to_sass(opts)
end

def val_to_sass_comma(node, opts)

def val_to_sass_comma(node, opts)
  return node unless node.is_a?(Sass::Script::Operation)
  return val_to_sass_concat(node, opts) unless node.operator == :comma
  Sass::Script::Operation.new(
    val_to_sass_concat(node.operand1, opts),
    val_to_sass_comma(node.operand2, opts),
    node.operator)
end

def val_to_sass_concat(node, opts)

def val_to_sass_concat(node, opts)
  return node unless node.is_a?(Sass::Script::Operation)
  return val_to_sass_div(node, opts) unless node.operator == :concat
  Sass::Script::Operation.new(
    val_to_sass_div(node.operand1, opts),
    val_to_sass_concat(node.operand2, opts),
    node.operator)
end

def val_to_sass_div(node, opts)

def val_to_sass_div(node, opts)
  unless node.is_a?(Sass::Script::Operation) && node.operator == :div &&
      node.operand1.is_a?(Sass::Script::Number) &&
      node.operand2.is_a?(Sass::Script::Number) &&
      (node.context == :equals || !node.operand1.original || !node.operand2.original)
    return node
  end
  Sass::Script::String.new("(#{node.to_sass(opts)})")
end