class Sass::Tree::PropNode
def ==(other)
-
(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 declaration
def declaration (@prop_syntax == :new ? "#{name}: #{value}" : ":#{name} #{value}").strip end
def initialize(name, value, prop_syntax)
-
prop_syntax
(Symbol
) -- `:new` if this property uses `a: b`-style syntax, -
value
(String
) -- See \{#value} -
name
(String
) -- See \{#name}
def initialize(name, value, prop_syntax) @name = name @value = value @prop_syntax = prop_syntax super() end
def invalid_child?(child)
-
(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)
-
environment
(Sass::Environment
) -- The lexical environment containing
def perform!(environment) @name = interpolate(@name, environment) @value = @value.is_a?(String) ? interpolate(@value, environment) : @value.perform(environment).to_s super end
def pseudo_class_selector_message
-
(String)
- The message
def pseudo_class_selector_message return "" if @prop_syntax == :new || !value.empty? "\nIf #{declaration.dump} should be a selector, use \"\\#{declaration}\" instead." end
def to_s(tabs, parent_name = nil)
-
(Sass::SyntaxError)
- if the property uses invalid syntax
Returns:
-
(String)
- The resulting CSS
Parameters:
-
parent_name
(String
) -- The name of the parent property (e.g. `text`) or nil -
tabs
(Fixnum
) -- The level of indentation for the CSS
def to_s(tabs, parent_name = nil) 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.", @line) 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.", @line) end if value[-1] == ?; raise Sass::SyntaxError.new("Invalid property: #{declaration.dump} (no \";\" required at end-of-line).", @line) end real_name = name real_name = "#{parent_name}-#{real_name}" if parent_name if value.empty? && children.empty? message = "Invalid property: #{declaration.dump} (no value)." + pseudo_class_selector_message raise Sass::SyntaxError.new(message, @line) end join_string = case style when :compact; ' ' when :compressed; '' else "\n" end spaces = ' ' * (tabs - 1) to_return = '' if !value.empty? to_return << "#{spaces}#{real_name}:#{style == :compressed ? '' : ' '}#{value};#{join_string}" end children.each do |kid| next if kid.invisible? to_return << kid.to_s(tabs, real_name) << join_string end (style == :compressed && parent_name) ? to_return : to_return[0...-1] end
def to_sass(tabs, opts = {})
- See: Node#to_sass -
def to_sass(tabs, opts = {}) "#{' ' * tabs}#{opts[:old] ? ':' : ''}#{name}#{opts[:old] ? '' : ':'} #{value}\n" end