Class Sass::Tree::CommentNode
In: lib/sass/tree/comment_node.rb
Parent: Node
Haml::Util Engine Color SyntaxError UnitConversionError StandardError Node Operation Literal UnaryOperation Funcall Variable Number String Bool EvaluationContext Node\n[lib/sass/css.rb\nlib/sass/tree/node.rb] DebugNode IfNode CommentNode ForNode MixinNode VariableNode ImportNode WhileNode MixinDefNode Repl CSS Environment Lexer Parser PropNode\n[lib/sass/css.rb\nlib/sass/tree/prop_node.rb] DirectiveNode\n[lib/sass/css.rb\nlib/sass/tree/directive_node.rb] RuleNode\n[lib/sass/css.rb\nlib/sass/tree/rule_node.rb] Rack lib/sass/repl.rb lib/sass/css.rb lib/sass/environment.rb lib/sass/error.rb lib/sass/engine.rb lib/sass/script/lexer.rb lib/sass/script/color.rb lib/sass/script/string.rb lib/sass/script/unary_operation.rb lib/sass/script/variable.rb lib/sass/script/funcall.rb lib/sass/script/operation.rb lib/sass/script/bool.rb lib/sass/script/parser.rb lib/sass/script/literal.rb lib/sass/script/node.rb lib/sass/script/number.rb lib/sass/script/functions.rb Functions Script Files lib/sass/tree/while_node.rb lib/sass/tree/if_node.rb lib/sass/tree/mixin_def_node.rb lib/sass/tree/debug_node.rb lib/sass/tree/for_node.rb lib/sass/tree/import_node.rb lib/sass/tree/prop_node.rb lib/sass/tree/node.rb lib/sass/tree/comment_node.rb lib/sass/tree/mixin_node.rb lib/sass/tree/directive_node.rb lib/sass/tree/rule_node.rb lib/sass/tree/variable_node.rb Tree lib/sass/plugin/rack.rb Plugin Sass dot/m_54_0.png

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

@see Sass::Tree

Methods

==   _perform   invisible?   new   to_s  

Attributes

lines  [RW]  The lines of text nested beneath the comment.

@return [Array<Sass::Engine::Line>]

silent  [RW]  Whether or not the comment is silent (that is, doesn‘t output to CSS).

@return [Boolean]

value  [RW]  The text on the same line as the comment starter.

@return [String]

Public Class methods

@param value [String] See \{value} @param silent [Boolean] See \{silent}

[Source]

    # File lib/sass/tree/comment_node.rb, line 25
25:     def initialize(value, silent)
26:       @lines = []
27:       @value = value[2..-1].strip
28:       @silent = silent
29:       super()
30:     end

Public Instance methods

Compares the contents of two comments.

@param other [Object] The object to compare with @return [Boolean] Whether or not this node and the other object

  are the same

[Source]

    # File lib/sass/tree/comment_node.rb, line 37
37:     def ==(other)
38:       self.class == other.class && value == other.value && silent == other.silent && lines == other.lines
39:     end

Returns `true` if this is a silent comment or the current style doesn‘t render comments.

@return [Boolean]

[Source]

    # File lib/sass/tree/comment_node.rb, line 67
67:     def invisible?
68:       style == :compressed || @silent
69:     end

Computes the CSS for the comment.

Returns `nil` if this is a silent comment or the current style doesn‘t render comments.

@overload to_s(tabs = 0) @param tabs [Fixnum] The level of indentation for the CSS @return [String, nil] The resulting CSS @see invisible?

[Source]

    # File lib/sass/tree/comment_node.rb, line 50
50:     def to_s(tabs = 0, _ = nil)
51:       return if invisible?
52:       spaces = '  ' * (tabs - 1)
53: 
54:       content = (value.split("\n") + lines.map {|l| l.text})
55:       return spaces + "/* */" if content.empty?
56:       content.map! {|l| (l.empty? ? "" : " ") + l}
57:       content.first.gsub!(/^ /, '')
58:       content.last.gsub!(%r{ ?\*/ *$}, '')
59: 
60:       spaces + "/* " + content.join(style == :compact ? '' : "\n#{spaces} *") + " */"
61:     end

Protected Instance methods

Removes this node from the tree if it‘s a silent comment.

@param environment [Sass::Environment] The lexical environment containing

  variable and mixin values

@return [Tree::Node, Array<Tree::Node>] The resulting static nodes @see Sass::Tree

[Source]

    # File lib/sass/tree/comment_node.rb, line 79
79:     def _perform(environment)
80:       return [] if @silent
81:       self
82:     end

[Validate]