Class: Hamlit::Parser

Inherits:
Object show all
Defined in:
lib/hamlit/parser.rb

Constant Summary collapse

AVAILABLE_OPTIONS =
%i[
  autoclose
  escape_html
  escape_attrs
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Parser

Returns a new instance of Parser.



20
21
22
23
24
25
# File 'lib/hamlit/parser.rb', line 20

def initialize(options = {})
  @options = HamlOptions.defaults.dup
  AVAILABLE_OPTIONS.each do |key|
    @options[key] = options[key]
  end
end

Instance Method Details

#call(template) ⇒ Object



27
28
29
30
31
# File 'lib/hamlit/parser.rb', line 27

def call(template)
  HamlParser.new(template, HamlOptions.new(@options)).parse
rescue ::Hamlit::HamlError => e
  error_with_lineno(e)
end