Sha256: 75be7d8ee54851afb318c276045e23a47b2a12b695fb18c064b1cb8f80d1b7a7

Contents?: true

Size: 822 Bytes

Versions: 3

Compression:

Stored size: 822 Bytes

Contents

# Hamlit::Parser uses original Haml::Parser to generate Haml AST.
# hamlit/parser/haml_* are modules originally in haml gem.

require 'hamlit/parser/haml_error'
require 'hamlit/parser/haml_util'
require 'hamlit/parser/haml_buffer'
require 'hamlit/parser/haml_compiler'
require 'hamlit/parser/haml_parser'
require 'hamlit/parser/haml_helpers'
require 'hamlit/parser/haml_options'

module Hamlit
  class Parser
    AVAILABLE_OPTIONS = %i[
      autoclose
      escape_html
      escape_attrs
    ].freeze

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hamlit-2.1.0 lib/hamlit/parser.rb
hamlit-2.0.2 lib/hamlit/parser.rb
hamlit-2.0.1 lib/hamlit/parser.rb