Class: Identizer::Renderer
- Inherits:
-
Object
- Object
- Identizer::Renderer
- Defined in:
- lib/identizer/renderer.rb
Overview
Minimal ERB renderer with a shared layout. Templates live under web/views and are rendered in a Context that exposes the passed locals plus an ‘h` escaping helper. No template-engine dependency — stdlib ERB only.
Defined Under Namespace
Classes: Context
Constant Summary collapse
- VIEWS_DIR =
File.("web/views", __dir__)
Instance Method Summary collapse
-
#initialize(layout: "layout") ⇒ Renderer
constructor
A new instance of Renderer.
- #render(template, **locals) ⇒ Object
-
#render_bare(template, **locals) ⇒ Object
Render a standalone template without the admin layout (e.g. the login form).
Constructor Details
#initialize(layout: "layout") ⇒ Renderer
Returns a new instance of Renderer.
12 13 14 15 |
# File 'lib/identizer/renderer.rb', line 12 def initialize(layout: "layout") @layout = layout @cache = {} end |
Instance Method Details
#render(template, **locals) ⇒ Object
17 18 19 20 |
# File 'lib/identizer/renderer.rb', line 17 def render(template, **locals) content = render_template(template, locals) render_template(@layout, locals.merge(content: content)) end |
#render_bare(template, **locals) ⇒ Object
Render a standalone template without the admin layout (e.g. the login form).
23 24 25 |
# File 'lib/identizer/renderer.rb', line 23 def (template, **locals) render_template(template, locals) end |