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
-
#lines ⇒ Array<Sass::Engine::Line>
The lines of text nested beneath the comment.
-
#silent ⇒ Boolean
Whether or not the comment is silent (that is, doesn’t output to CSS).
-
#value ⇒ String
The text on the same line as the comment starter.
Attributes inherited from Node
#children, #filename, #line, #options
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares the contents of two comments.
-
#initialize(value, silent) ⇒ 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.
-
#to_s(tabs = 0) ⇒ String?
Computes the CSS for the comment.
Methods inherited from Node
#<<, #last, #perform, #render, #style, #to_sass
Constructor Details
#initialize(value, silent) ⇒ CommentNode
Returns a new instance of CommentNode.
25 26 27 28 29 30 |
# File 'lib/sass/tree/comment_node.rb', line 25 def initialize(value, silent) @lines = [] @value = value[2..-1].strip @silent = silent super() end |
Instance Attribute Details
#lines ⇒ Array<Sass::Engine::Line>
The lines of text nested beneath the comment.
11 12 13 |
# File 'lib/sass/tree/comment_node.rb', line 11 def lines @lines end |
#silent ⇒ Boolean
Whether or not the comment is silent (that is, doesn’t output to CSS).
21 22 23 |
# File 'lib/sass/tree/comment_node.rb', line 21 def silent @silent end |
#value ⇒ String
The text on the same line as the comment starter.
16 17 18 |
# File 'lib/sass/tree/comment_node.rb', line 16 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean
Compares the contents of two comments.
37 38 39 |
# File 'lib/sass/tree/comment_node.rb', line 37 def ==(other) self.class == other.class && value == other.value && silent == other.silent && lines == other.lines end |
#invisible? ⇒ Boolean
Returns ‘true` if this is a silent comment or the current style doesn’t render comments.
62 63 64 |
# File 'lib/sass/tree/comment_node.rb', line 62 def invisible? style == :compressed || @silent end |
#to_s(tabs = 0) ⇒ String?
Computes the CSS for the comment.
Returns ‘nil` if this is a silent comment or the current style doesn’t render comments.
50 51 52 53 54 55 56 |
# File 'lib/sass/tree/comment_node.rb', line 50 def to_s(tabs = 0, _ = nil) return if invisible? spaces = ' ' * (tabs - 1) spaces + "/* " + (value.split("\n") + lines.map {|l| l.text}). map{|l| l.sub(%r{ ?\*/ *$},'')}.join(style == :compact ? ' ' : "\n#{spaces} * ") + " */" end |