Class: Haml::Parser::ParseNode

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/haml.rb

Instance Method Summary collapse

Instance Method Details

#accept(visitor) ⇒ Object

Here we’re going to hook into the parse node and define a method that will accept a visitor in order to walk through the tree.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/syntax_tree/haml.rb', line 60

def accept(visitor)
  case type
  in :comment
    visitor.visit_comment(self)
  in :doctype
    visitor.visit_doctype(self)
  in :filter
    visitor.visit_filter(self)
  in :haml_comment
    visitor.visit_haml_comment(self)
  in :plain
    visitor.visit_plain(self)
  in :root
    visitor.visit_root(self)
  in :script
    visitor.visit_script(self)
  in :silent_script
    visitor.visit_silent_script(self)
  in :tag
    visitor.visit_tag(self)
  end
end

#format(q) ⇒ Object



83
84
85
# File 'lib/syntax_tree/haml.rb', line 83

def format(q)
  accept(SyntaxTree::Haml::Format.new(q))
end

#pretty_print(q) ⇒ Object



87
88
89
# File 'lib/syntax_tree/haml.rb', line 87

def pretty_print(q)
  accept(SyntaxTree::Haml::PrettyPrint.new(q))
end