Parent

Class/Module Index [+]

Quicksearch

Sass::Tree::PropNode

A static node reprenting a CSS property.

@see Sass::Tree

Attributes

name[RW]

The name of the property, interspersed with {Sass::Script::Node}s representing `#{}`-interpolation. Any adjacent strings will be merged together.

@return [Array<String, Sass::Script::Node>]

resolved_name[RW]

The name of the property after any interpolated SassScript has been resolved. Only set once {Tree::Visitors::Perform} has been run.

@return [String]

resolved_value[RW]

The value of the property after any interpolated SassScript has been resolved. Only set once {Tree::Visitors::Perform} has been run.

@return [String]

tabs[RW]

How deep this property is indented relative to a normal property. This is only greater than 0 in the case that:

  • This node is in a CSS tree

  • The style is :nested

  • This is a child property of another property

  • The parent property has a value, and thus will be rendered

@return [Fixnum]

value[RW]

The value of the property.

@return [Sass::Script::Node]

Public Instance Methods

==(other) click to toggle source

Compares the names and values of two properties.

@param other [Object] The object to compare with @return [Boolean] Whether or not this node and the other object

are the same
# File lib/sass/tree/prop_node.rb, line 63
def ==(other)
  self.class == other.class && name == other.name && value == other.value && super
end
declaration(opts = {:old => @prop_syntax == :old}, fmt = :sass) click to toggle source

Computes the Sass or SCSS code for the variable declaration. This is like {#to_scss} or {#to_sass}, except it doesn’t print any child properties or a trailing semicolon.

@param opts [{Symbol => Object}] The options hash for the tree. @param fmt [Symbol] `:scss` or `:sass`.

# File lib/sass/tree/prop_node.rb, line 83
def declaration(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 ? '' : ':'
  "#{initial}#{name}#{mid} #{self.class.val_to_sass(value, opts)}".rstrip
end
pseudo_class_selector_message() click to toggle source

Returns a appropriate message indicating how to escape pseudo-class selectors. This only applies for old-style properties with no value, so returns the empty string if this is new-style.

@return [String] The message

# File lib/sass/tree/prop_node.rb, line 72
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

Public Class Methods

new(name, value, prop_syntax) click to toggle source

@param name [Array<String, Sass::Script::Node>] See {#name} @param value [Sass::Script::Node] See {#value} @param prop_syntax [Symbol] `:new` if this property uses `a: b`-style syntax,

`:old` if it uses `:a b`-style syntax
# File lib/sass/tree/prop_node.rb, line 49
def initialize(name, value, prop_syntax)
  @name = Sass::Util.strip_string_array(
    Sass::Util.merge_adjacent_strings(name))
  @value = value
  @tabs = 0
  @prop_syntax = prop_syntax
  super()
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.