Class: FastHaml::Parser
- Inherits:
-
Object
- Object
- FastHaml::Parser
- Defined in:
- lib/fast_haml/parser.rb
Instance Method Summary collapse
- #call(template_str) ⇒ Object
-
#initialize(options = {}) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(options = {}) ⇒ Parser
Returns a new instance of Parser.
13 14 |
# File 'lib/fast_haml/parser.rb', line 13 def initialize( = {}) end |
Instance Method Details
#call(template_str) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fast_haml/parser.rb', line 16 def call(template_str) @ast = Ast::Root.new @stack = [] @line_parser = LineParser.new(template_str) @indent_tracker = IndentTracker.new(on_enter: method(:indent_enter), on_leave: method(:indent_leave)) @filter_parser = FilterParser.new(@indent_tracker) while @line_parser.has_next? line = @line_parser.next_line if !@ast.is_a?(Ast::HamlComment) && @filter_parser.enabled? ast = @filter_parser.append(line) if ast @ast << ast end end unless @filter_parser.enabled? parse_line(line) end end ast = @filter_parser.finish if ast @ast << ast end @indent_tracker.finish @ast end |