Class: SyntaxTree::Haml::Comment
- Inherits:
-
Object
- Object
- SyntaxTree::Haml::Comment
- Defined in:
- lib/syntax_tree/haml/comment.rb
Overview
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #format(q) ⇒ Object
-
#initialize(node) ⇒ Comment
constructor
A new instance of Comment.
- #pretty_print(q) ⇒ Object
Constructor Details
#initialize(node) ⇒ Comment
Returns a new instance of Comment.
9 10 11 |
# File 'lib/syntax_tree/haml/comment.rb', line 9 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
7 8 9 |
# File 'lib/syntax_tree/haml/comment.rb', line 7 def node @node end |
Instance Method Details
#format(q) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/syntax_tree/haml/comment.rb', line 13 def format(q) Haml.with_children(node, q) do q.text("/") q.text("!") if node.value[:revealed] if node.value[:conditional] q.text(node.value[:conditional]) elsif node.value[:text] q.text(" #{node.value[:text]}") end end end |
#pretty_print(q) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/syntax_tree/haml/comment.rb', line 26 def pretty_print(q) q.group(2, "(comment", ")") do q.breakable if node.value[:conditional] q.text("conditional=") q.pp(node.value[:conditional]) elsif node.value[:text] q.text("text=") q.pp(node.value[:text]) end if node.value[:revealed] q.breakable q.text("revealed") end if node.children.any? q.breakable q.text("children=") q.pp(node.children) end end end |