1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Sass] Rename AttrNode to PropNode.

This commit is contained in:
Nathan Weizenbaum 2009-06-19 03:49:40 -07:00
parent 81900a6db5
commit 282009c85d
5 changed files with 12 additions and 12 deletions

View file

@ -24,7 +24,7 @@ module Sass
class RuleNode class RuleNode
# @see Node#to_sass # @see Node#to_sass
def to_sass(tabs, opts = {}) def to_sass(tabs, opts = {})
str = "\n#{' ' * tabs}#{rules.first}#{children.any? { |c| c.is_a? AttrNode } ? "\n" : ''}" str = "\n#{' ' * tabs}#{rules.first}#{children.any? { |c| c.is_a? PropNode } ? "\n" : ''}"
children.each do |child| children.each do |child|
str << "#{child.to_sass(tabs + 1, opts)}" str << "#{child.to_sass(tabs + 1, opts)}"
@ -34,7 +34,7 @@ module Sass
end end
end end
class AttrNode class PropNode
# @see Node#to_sass # @see Node#to_sass
def to_sass(tabs, opts = {}) def to_sass(tabs, opts = {})
"#{' ' * tabs}#{opts[:old] ? ':' : ''}#{name}#{opts[:old] ? '' : ':'} #{value}\n" "#{' ' * tabs}#{opts[:old] ? ':' : ''}#{name}#{opts[:old] ? '' : ':'} #{value}\n"
@ -155,7 +155,7 @@ module Sass
end end
assert_match /(;|(?=\}))/ assert_match /(;|(?=\}))/
rule << Tree::AttrNode.new(name, value, nil) rule << Tree::PropNode.new(name, value, nil)
end end
assert_match /\}/ assert_match /\}/

View file

@ -3,7 +3,7 @@ require 'digest/sha1'
require 'sass/tree/node' require 'sass/tree/node'
require 'sass/tree/rule_node' require 'sass/tree/rule_node'
require 'sass/tree/comment_node' require 'sass/tree/comment_node'
require 'sass/tree/attr_node' require 'sass/tree/prop_node'
require 'sass/tree/directive_node' require 'sass/tree/directive_node'
require 'sass/tree/variable_node' require 'sass/tree/variable_node'
require 'sass/tree/mixin_def_node' require 'sass/tree/mixin_def_node'
@ -335,7 +335,7 @@ END
else else
value value
end end
Tree::AttrNode.new(name, expr, property_regx == PROPERTY_OLD ? :old : :new) Tree::PropNode.new(name, expr, property_regx == PROPERTY_OLD ? :old : :new)
end end
def parse_variable(line) def parse_variable(line)

View file

@ -41,7 +41,7 @@ module Sass::Tree
children.each do |child| children.each do |child|
next if child.invisible? next if child.invisible?
if style == :compact if style == :compact
if child.is_a?(AttrNode) if child.is_a?(PropNode)
result << "#{child.to_s(first || was_prop ? 1 : tabs + 1)} " result << "#{child.to_s(first || was_prop ? 1 : tabs + 1)} "
else else
if was_prop if was_prop
@ -51,11 +51,11 @@ module Sass::Tree
rendered.lstrip! if first rendered.lstrip! if first
result << rendered result << rendered
end end
was_prop = child.is_a?(AttrNode) was_prop = child.is_a?(PropNode)
first = false first = false
elsif style == :compressed elsif style == :compressed
result << (was_prop ? ";#{child.to_s(1)}" : child.to_s(1)) result << (was_prop ? ";#{child.to_s(1)}" : child.to_s(1))
was_prop = child.is_a?(AttrNode) was_prop = child.is_a?(PropNode)
else else
result << child.to_s(tabs + 1) + "\n" result << child.to_s(tabs + 1) + "\n"
end end

View file

@ -122,7 +122,7 @@ module Sass
def to_s def to_s
result = String.new result = String.new
children.each do |child| children.each do |child|
if child.is_a? AttrNode if child.is_a? PropNode
raise Sass::SyntaxError.new('Properties aren\'t allowed at the root of a document.', child.line) raise Sass::SyntaxError.new('Properties aren\'t allowed at the root of a document.', child.line)
else else
next if child.invisible? next if child.invisible?

View file

@ -2,7 +2,7 @@ module Sass::Tree
# A static node reprenting a CSS property. # A static node reprenting a CSS property.
# #
# @see Sass::Tree # @see Sass::Tree
class AttrNode < Node class PropNode < Node
# The name of the property. # The name of the property.
# #
# @return [String] # @return [String]
@ -91,11 +91,11 @@ module Sass::Tree
# Returns an error message if the given child node is invalid, # Returns an error message if the given child node is invalid,
# and false otherwise. # and false otherwise.
# #
# {AttrNode} only allows other {AttrNode}s and {CommentNode}s as children. # {PropNode} only allows other {PropNode}s and {CommentNode}s as children.
# @param child [Tree::Node] A potential child node # @param child [Tree::Node] A potential child node
# @return [String] An error message if the child is invalid, or nil otherwise # @return [String] An error message if the child is invalid, or nil otherwise
def invalid_child?(child) def invalid_child?(child)
if !child.is_a?(AttrNode) && !child.is_a?(CommentNode) if !child.is_a?(PropNode) && !child.is_a?(CommentNode)
"Illegal nesting: Only properties may be nested beneath properties." "Illegal nesting: Only properties may be nested beneath properties."
end end
end end