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
-
#loud ⇒ Boolean
Whether the comment is loud.
-
#silent ⇒ Boolean
Whether or not the comment is silent (that is, doesn't output to CSS).
-
#value ⇒ String
The text of the comment, not including
/*
and*/
.
Attributes inherited from Node
#children, #filename, #has_children, #line, #options
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares the contents of two comments.
-
#evaluated? ⇒ Boolean
Returns whether this comment should be interpolated for dynamic comment generation.
-
#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.
Methods inherited from Node
#<<, #balance, #deep_copy, #do_extend, #each, #style, #to_s, #to_sass, #to_scss
Constructor Details
#initialize(value, silent) ⇒ CommentNode
Returns a new instance of CommentNode.
28 29 30 31 32 33 34 35 |
# File 'lib/sass/tree/comment_node.rb', line 28
def initialize(value, silent)
@lines = []
@silent = silent
@value = normalize_indentation value
@loud = @value =~ %r{^(/[\/\*])?!}
@value.sub!("#{$1}!", $1.to_s) if @loud
super()
end
|
Instance Attribute Details
#loud ⇒ Boolean
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.
19 20 21 |
# File 'lib/sass/tree/comment_node.rb', line 19
def loud
@loud
end
|
#silent ⇒ Boolean
Whether or not the comment is silent (that is, doesn't output to CSS).
24 25 26 |
# File 'lib/sass/tree/comment_node.rb', line 24
def silent
@silent
end
|
#value ⇒ String
The text of the comment, not including /*
and */
.
11 12 13 |
# File 'lib/sass/tree/comment_node.rb', line 11
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 && silent == other.silent
end
|
#evaluated? ⇒ Boolean
Returns whether this comment should be interpolated for dynamic comment generation.
61 62 63 |
# File 'lib/sass/tree/comment_node.rb', line 61
def evaluated?
@loud
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?
if @loud
return false
else
@silent || (style == :compressed)
end
end
|