class Hamlit::Parser

Constants

AVAILABLE_OPTIONS

Public Class Methods

new(options = {}) click to toggle source
# 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

Public Instance Methods

call(template) click to toggle source
# 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

Private Instance Methods

error_with_lineno(error) click to toggle source
# File lib/hamlit/parser.rb, line 35
def error_with_lineno(error)
  return error if error.line

  trace = error.backtrace.first
  return error unless trace

  line = trace.match(/\d+\z/).to_s.to_i
  HamlSyntaxError.new(error.message, line)
end