Sha256: 94ee90eec26d4ac7e8f39bbeef6f0e531eee2ab46fefdcbbb38de5198f6f5637

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true
require 'temple'
require 'haml/parser'
require 'haml/compiler'
require 'haml/html'
require 'haml/string_splitter'
require 'haml/escapable'
require 'haml/force_escapable'
require 'haml/dynamic_merger'
require 'haml/ambles'
require 'haml/whitespace'

module Haml
  class Engine < Temple::Engine
    define_options(
      :buffer_class,
      generator:    Temple::Generators::StringBuffer,
      format:       :html,
      attr_quote:   "'",
      escape_html:  true,
      escape_attrs: true,
      autoclose:    %w(area base basefont br col command embed frame
                       hr img input isindex keygen link menuitem meta
                       param source track wbr),
      filename:     "",
      disable_capture: false,
      remove_whitespace: false,
    )

    use Parser
    use Compiler
    use HTML
    use StringSplitter
    filter :StaticAnalyzer
    use Escapable
    use ForceEscapable
    filter :ControlFlow
    use Ambles
    filter :MultiFlattener
    use Whitespace
    filter :StaticMerger
    use DynamicMerger
    use :Generator, -> { options[:generator] }
  end

  # For backward compatibility of Tilt integration. TODO: We should deprecate this
  # and let Tilt have a native support of Haml 6. At least it generates warnings now.
  class TempleEngine < Engine
    def compile(template)
      @precompiled = call(template)
    end

    def precompiled_with_ambles(_local_names, after_preamble:)
      "#{after_preamble.tr("\n", ';')}#{@precompiled}".dup
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
haml-6.0.12-java lib/haml/engine.rb
haml-6.0.12 lib/haml/engine.rb
haml-6.0.11-java lib/haml/engine.rb
haml-6.0.11 lib/haml/engine.rb