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.
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.
::Tilt.default_mapping.dup.tap { |mapping| # Unregister any existing mappings for the extensions we provide our own engines for. # # Tilt preferences non-lazy registrations over lazy ones (see `Tilt::Mapping#lookup`). So if # "haml" or "slim" has been required before this mapping is built (each of which registers # its own non-lazy mapping with Tilt), our own lazy-registered adapters below would be # shadowed and never picked up, and templates would render without our specific required # behavior. # # Unregistering first ensures our engines are always used, regardless of load order. mapping.unregister "erb", "rhtml", "haml", "slim" # Register our own ERB template. mapping.register_lazy "Hanami::View::ERB::Template", "hanami/view/erb/template", "erb", "rhtml" # Register templates for Haml and Slim that set the `use_html_safe: true` option. # # We register these lazily so that the optional "haml" and "slim" gems only need to be # installed when their templates are actually used. # # 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.
43 44 45 |
# File 'lib/hanami/view/tilt.rb', line 43 def [](path, mapping, ) with_mapping(mapping).new(path, ) end |