Class: PortBay::ErbStamper::Railtie
- Inherits:
-
Rails::Railtie
- Object
- Rails::Railtie
- PortBay::ErbStamper::Railtie
- Defined in:
- lib/portbay/erb_stamper/railtie.rb
Overview
The install seam: a Railtie, which Rails loads automatically for every gem
in the Gemfile. Nothing to register, no initializer to paste, no
config/application.rb edit — the same "install and it is on" property
Laravel's package auto-discovery gives the Blade lane.
Why this registers eagerly instead of on a load hook
The idiomatic-looking spelling is
ActiveSupport.on_load(:action_view) { ... }, and it silently does
nothing. That hook fires when ActionView::Base is really loaded, which
in a fresh process does not happen until something renders — so the
handler is registered AFTER the first template has already compiled
without it, and never at all in a process that renders nothing. Measured,
not reasoned: with the hook form, bin/rails runner reported
handler_for_extension(:erb) as the stock ActionView::Template::Handlers::ERB
and a served page came back with zero stamps.
Naming ActionView::Template here instead forces its autoload, which runs
ActionView::Template::Handlers.extended and its stock :erb
registration first; this call then replaces that entry. Registering into
ActionView's own handler table is the documented way to supply a handler,
and it is why none of this needs the application to own its boot.