Class: Hamli::Parser

Inherits:
Temple::Parser
  • Object
show all
Defined in:
lib/hamli/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(_options = {}) ⇒ Parser

Returns a new instance of Parser.



11
12
13
14
# File 'lib/hamli/parser.rb', line 11

def initialize(_options = {})
  super
  @file_path = options[:file] || '(__TEMPLATE__)'
end

Instance Method Details

#call(source) ⇒ Array

Parameters:

  • source (String)

    Haml template source.

Returns:

  • (Array)


18
19
20
21
22
23
24
# File 'lib/hamli/parser.rb', line 18

def call(source)
  @stacks = [%i[multi]]
  @indents = []
  @scanner = ::StringScanner.new(source)
  parse_block until @scanner.eos?
  @stacks[0]
end