Module: SyntaxTree::Haml
- Defined in:
- lib/syntax_tree/haml/tag.rb,
lib/syntax_tree/haml/root.rb,
lib/syntax_tree/haml/plain.rb,
lib/syntax_tree/haml/filter.rb,
lib/syntax_tree/haml/script.rb,
lib/syntax_tree/haml/comment.rb,
lib/syntax_tree/haml/doctype.rb,
lib/syntax_tree/haml/version.rb,
lib/syntax_tree/haml/haml_comment.rb,
lib/syntax_tree/haml/silent_script.rb,
lib/syntax_tree/haml.rb
Defined Under Namespace
Classes: Comment, Doctype, Filter, HamlComment, Plain, Root, Script, SilentScript, Tag
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Method Summary
collapse
Class Method Details
50
51
52
53
54
55
56
|
# File 'lib/syntax_tree/haml.rb', line 50
def self.format(source)
formatter = PP.new([])
parse(source).format(formatter)
formatter.flush
formatter.output.join
end
|
.parse(source) ⇒ Object
46
47
48
|
# File 'lib/syntax_tree/haml.rb', line 46
def self.parse(source)
::Haml::Parser.new({}).call(source)
end
|
.with_children(node, q) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/syntax_tree/haml.rb', line 58
def self.with_children(node, q)
if node.children.empty?
q.group { yield }
else
q.group do
q.group { yield }
q.indent do
node.children.each do |child|
q.breakable(force: true)
child.format(q)
end
end
end
end
end
|