Class: Hamlit::Parser
Constant Summary collapse
- AVAILABLE_OPTIONS =
%i[ autoclose escape_html escape_attrs ].freeze
Instance Method Summary collapse
- #call(template) ⇒ Object
-
#initialize(options = {}) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(options = {}) ⇒ Parser
Returns a new instance of Parser.
25 26 27 28 29 30 |
# File 'lib/hamlit/parser.rb', line 25 def initialize( = {}) @options = HamlOptions.defaults.dup AVAILABLE_OPTIONS.each do |key| @options[key] = [key] end end |
Instance Method Details
#call(template) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/hamlit/parser.rb', line 32 def call(template) template = Hamlit::HamlUtil.check_haml_encoding(template) do |msg, line| raise Hamlit::Error.new(msg, line) end HamlParser.new(HamlOptions.new(@options)).call(template) rescue ::Hamlit::HamlError => e error_with_lineno(e) end |