Class: Sass::Tree::CommentNode

Inherits:
Node
  • Object
show all
Defined in:
lib/sass/tree/comment_node.rb

Overview

A static node representing a Sass comment (silent or loud).

See Also:

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #filename, #has_children, #line, #options

Instance Method Summary collapse

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.

Parameters:



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

#loudBoolean

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.

Returns:

  • (Boolean)


19
20
21
# File 'lib/sass/tree/comment_node.rb', line 19

def loud
  @loud
end

#silentBoolean

Whether or not the comment is silent (that is, doesn't output to CSS).

Returns:

  • (Boolean)


24
25
26
# File 'lib/sass/tree/comment_node.rb', line 24

def silent
  @silent
end

#valueString

The text of the comment, not including /* and */.

Returns:

  • (String)


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.

Parameters:

  • other (Object)

    The object to compare with

Returns:

  • (Boolean)

    Whether or not this node and the other object are the same



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.

Returns:

  • (Boolean)


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.)

Returns:

  • (Boolean)


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