Class: Abqari::RenderContext

Inherits:
Object
  • Object
show all
Includes:
Helpers, CoverHelpers, PictureHelpers, PublicationHelpers
Defined in:
lib/abqari/render_context.rb,
lib/abqari/render_context/cover_helpers.rb,
lib/abqari/render_context/picture_helpers.rb,
lib/abqari/render_context/publication_helpers.rb

Overview

The binding ERB templates execute against. Holds references to the current page and site, includes shared helper mixins.

Decomposed for readability — the helpers split into:

- `Helpers`              : core scalar helpers (h, sanitized_url,
                          local_time, pluralize, truncate, link_to,
                          slugify, …). Engine-wide.
- `PublicationHelpers`   : publication/bundle/series accessors,
                          buy/cart buttons. Publisher-agnostic —
                          see lib/abqari/render_context/
                          publication_helpers.rb.
- `PictureHelpers`       : asset_path, icon, heroicon, picture_tag,
                          bundle_picture_tag, bundle_asset_url.

Templating-specific surface (render, render_layout, render_string, yield_content, get_binding) stays here.

Defined Under Namespace

Modules: CoverHelpers, PictureHelpers, PublicationHelpers

Constant Summary collapse

TEMPLATE_PUBLIC_IVARS =

Instance variables intentionally exposed to templates via the binding ERB receives. Anything outside this set should use the @_ convention so a stray <%= @foo %> is clearly out-of- contract. The audit test RenderContextInternalIvarTest reads this list and fails if RenderContext grows an ivar that's neither in the allow-list nor @_-prefixed.

%i[@page @site].freeze
RESERVED_LOCALS =

Local names that must never be shadowed by a render(..., key: v) local — doing so would silently replace the escaping function or a core API method for that partial. page is deliberately NOT here: rebinding it (render 'partials/card', page: item) is a supported pattern.

%i[h sanitized_url site render render_layout render_string
script_safe_json get_binding yield_content].freeze

Constants included from CoverHelpers

CoverHelpers::COVER_MODES, CoverHelpers::COVER_PALETTES, CoverHelpers::DEFAULT_COVER_MODE, CoverHelpers::THEME_COVER_PALETTES

Constants included from PictureHelpers

PictureHelpers::HEROICON_VARIANTS

Constants included from Helpers

Helpers::NON_DECOMPOSING_LETTERS, Helpers::NON_DECOMPOSING_LETTERS_RE, Helpers::SCRIPT_JSON_ESCAPE, Helpers::SCRIPT_JSON_RE

Instance Attribute Summary collapse

Instance Method Summary collapse