Class: InertiaJb::Handler
- Inherits:
-
Object
- Object
- InertiaJb::Handler
- Defined in:
- lib/inertia_jb/handler.rb
Overview
ActionView template handler for *.html.inertia templates.
An .html.inertia template is jb-style Ruby: its last expression is a Hash
of Inertia props. We evaluate it, then hand the resulting Hash to
Renderer, whose return value becomes the rendered body.
Unlike props_template, there is no shared builder state to guard: jb
partials each return their own Hash independently, so no @__json-style
finalize dance is needed here.
Class Method Summary collapse
Class Method Details
.call(template, source = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/inertia_jb/handler.rb', line 14 def self.call(template, source = nil) source ||= template.source # `begin;#{source}` keeps the template's own line numbers aligned in # backtraces. The begin/end block evaluates to the template's last # expression (the props Hash). "__inertia_props = begin;#{source}\nend\n" \ "::InertiaJb::Renderer.new(self, __inertia_props, true).render" end |