Module: Hanami::View::Tilt Private

Defined in:
lib/hanami/view/tilt.rb,
lib/hanami/view/tilt/haml_adapter.rb,
lib/hanami/view/tilt/slim_adapter.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0

Defined Under Namespace

Modules: HamlAdapter, SlimAdapter

Constant Summary collapse

Mapping =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0

::Tilt.default_mapping.dup.tap { |mapping|
  # If "slim" has been required before "hanami/view", unregister Slim's non-lazy registered
  # template, so our own template adapter (using register_lazy below) can take precedence.
  mapping.unregister "slim"

  # Register our own ERB template.
  mapping.register_lazy "Hanami::View::ERB::Template", "hanami/view/erb/template", "erb", "rhtml"

  # Register ERB templates for Haml and Slim that set the `use_html_safe: true` option.
  #
  # Our template namespaces below have the "Adapter" suffix to work around a bug in Tilt's
  # `Mapping#const_defined?`, which (if slim was already required) would receive
  # "Hanami::View::Slim::Template" and return `Slim::Template`, which is the opposite of what
  # we want.
  mapping.register_lazy "Hanami::View::Tilt::HamlAdapter::Template", "hanami/view/tilt/haml_adapter", "haml"
  mapping.register_lazy "Hanami::View::Tilt::SlimAdapter::Template", "hanami/view/tilt/slim_adapter", "slim"
}

Class Method Summary collapse

Class Method Details

.[](path, mapping, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0



33
34
35
# File 'lib/hanami/view/tilt.rb', line 33

def [](path, mapping, options)
  with_mapping(mapping).new(path, options)
end