Sha256: f4ccfcac7fb7a4ec1d551b578d5f7774d8cb047c5778ce324878b67b90313030

Contents?: true

Size: 1.4 KB

Versions: 12

Compression:

Stored size: 1.4 KB

Contents

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

module Haml
  class Engine < Temple::Engine
    define_options(
      :buffer_class,
      generator:    Temple::Generators::ArrayBuffer,
      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,
    )

    use Parser
    use Compiler
    use HTML
    filter :StringSplitter
    filter :StaticAnalyzer
    use Escapable
    use ForceEscapable
    filter :ControlFlow
    use Ambles
    filter :MultiFlattener
    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

12 entries across 12 versions & 1 rubygems

Version Path
haml-6.0.3-java lib/haml/engine.rb
haml-6.0.3 lib/haml/engine.rb
haml-6.0.2-java lib/haml/engine.rb
haml-6.0.2 lib/haml/engine.rb
haml-6.0.1-java lib/haml/engine.rb
haml-6.0.1 lib/haml/engine.rb
haml-6.0.0-java lib/haml/engine.rb
haml-6.0.0 lib/haml/engine.rb
haml-6.0.0.beta.2-java lib/haml/engine.rb
haml-6.0.0.beta.2 lib/haml/engine.rb
haml-6.0.0.beta.1-java lib/haml/engine.rb
haml-6.0.0.beta.1 lib/haml/engine.rb