Class: Sass::Tree::CommentNode
- Defined in:
- lib/sass/tree/comment_node.rb
Overview
A static node representing a Sass comment (silent or loud).
Instance Attribute Summary collapse
-
#resolved_value ⇒ String
The text of the comment after any interpolated SassScript has been resolved.
-
#type ⇒ Symbol
The type of the comment.
-
#value ⇒ Array<String, Sass::Script::Tree::Node>
The text of the comment, not including
/*
and*/
.
Attributes inherited from Node
#children, #filename, #has_children, #line, #options, #source_range
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares the contents of two comments.
-
#initialize(value, type) ⇒ CommentNode
constructor
A new instance of CommentNode.
-
#invisible? ⇒ Boolean
Returns
true
if this is a silent comment or the current style doesn't render comments. -
#lines ⇒ Integer
Returns the number of lines in the comment.
Methods inherited from Node
#<<, #balance, #bubbles?, #css, #css_with_sourcemap, #deep_copy, #each, #inspect, #style, #to_sass, #to_scss
Constructor Details
#initialize(value, type) ⇒ CommentNode
Returns a new instance of CommentNode.
31 32 33 34 35 |
# File 'lib/sass/tree/comment_node.rb', line 31
def initialize(value, type)
@value = Sass::Util.with_extracted_values(value) {|str| normalize_indentation str}
@type = type
super()
end
|
Instance Attribute Details
#resolved_value ⇒ String
The text of the comment after any interpolated SassScript has been resolved. Only set once Visitors::Perform has been run.
20 21 22 |
# File 'lib/sass/tree/comment_node.rb', line 20
def resolved_value
@resolved_value
end
|
#type ⇒ Symbol
The type of the comment. :silent
means it's never output to CSS,
:normal
means it's output in every compile mode except :compressed
,
and :loud
means it's output even in :compressed
.
27 28 29 |
# File 'lib/sass/tree/comment_node.rb', line 27
def type
@type
end
|
#value ⇒ Array<String, Sass::Script::Tree::Node>
The text of the comment, not including /*
and */
.
Interspersed with Script::Tree::Nodes representing #{}
-interpolation
if this is a loud comment.
13 14 15 |
# File 'lib/sass/tree/comment_node.rb', line 13
def value
@value
end
|
Instance Method Details
#==(other) ⇒ Boolean
Compares the contents of two comments.
42 43 44 |
# File 'lib/sass/tree/comment_node.rb', line 42
def ==(other)
self.class == other.class && value == other.value && type == other.type
end
|
#invisible? ⇒ Boolean
Returns true
if this is a silent comment
or the current style doesn't render comments.
Comments starting with ! are never invisible (and the ! is removed from the output.)
52 53 54 55 56 57 58 |
# File 'lib/sass/tree/comment_node.rb', line 52
def invisible?
case @type
when :loud; false
when :silent; true
else; style == :compressed
end
end
|
#lines ⇒ Integer
Returns the number of lines in the comment.
63 64 65 66 67 68 |
# File 'lib/sass/tree/comment_node.rb', line 63
def lines
@value.inject(0) do |s, e|
next s + e.count("\n") if e.is_a?(String)
next s
end
end
|