Class: Sass::Tree::CommentNode
- Inherits:
-
Node
- Object
- Node
- Sass::Tree::CommentNode
- Defined in:
- /var/www/sass-pages/.sass/lib/sass/tree/comment_node.rb
Overview
A static node representing a Sass comment (silent or loud).
Instance Attribute Summary
- - (Boolean) loud Whether the comment is loud.
- - (String) resolved_value The text of the comment after any interpolated SassScript has been resolved.
- - (Boolean) silent Whether or not the comment is silent (that is, doesn’t output to CSS).
-
- (Array<String, Sass::Script::Node>) value
The text of the comment, not including
/*and*/.
Instance Method Summary
- - (Boolean) =(other) Compares the contents of two comments.
- - (CommentNode) initialize(value, silent, loud) constructor A new instance of CommentNode.
-
- (Boolean) invisible?
Returns
trueif this is a silent comment or the current style doesn’t render comments. - - (Fixnum) lines Returns the number of lines in the comment.
Methods inherited from Node
#<<, #balance, #deep_copy, #do_extend, #each, #inspect, #style, #to_s, #to_sass, #to_scss
Constructor Details
- (CommentNode) initialize(value, silent, loud)
A new instance of CommentNode
38 39 40 41 42 43 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/comment_node.rb', line 38
def initialize(value, silent, loud)
@value = Sass::Util.with_extracted_values(value) {|str| normalize_indentation str}
@silent = silent
@loud = loud
super()
end
|
Instance Attribute Details
- (Boolean) loud
Whether the comment is loud.
Loud comments start with ! and force the comment to be generated irrespective of compilation settings or the comment syntax used.
28 29 30 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/comment_node.rb', line 28
def loud
@loud
end
|
- (String) resolved_value
The text of the comment after any interpolated SassScript has been resolved. Only set once Tree::Visitors::Perform has been run.
20 21 22 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/comment_node.rb', line 20
def resolved_value
@resolved_value
end
|
- (Boolean) silent
Whether or not the comment is silent (that is, doesn’t output to CSS).
33 34 35 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/comment_node.rb', line 33
def silent
@silent
end
|
- (Array<String, Sass::Script::Node>) value
The text of the comment, not including /* and */. Interspersed with Sass::Script::Nodes representing #{}-interpolation if this is a loud comment.
13 14 15 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/comment_node.rb', line 13
def value
@value
end
|
Instance Method Details
- (Boolean) ==(other)
Compares the contents of two comments.
50 51 52 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/comment_node.rb', line 50
def ==(other)
self.class == other.class && value == other.value && silent == other.silent && loud == other.loud
end
|
- (Boolean) invisible?
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.)
60 61 62 63 64 65 66 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/comment_node.rb', line 60
def invisible?
if @loud
return false
else
@silent || (style == :compressed)
end
end
|
- (Fixnum) lines
Returns the number of lines in the comment.
71 72 73 74 75 76 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/comment_node.rb', line 71
def lines
@value.inject(0) do |s, e|
next s + e.count("\n") if e.is_a?(String)
next s
end
end
|