Skip to content

fix(frond): zero-arg callable globals auto-call (ADR-0085) - #251

Merged
tina4stack merged 1 commit into
v3from
fix/frond-align-globals-v2
Oct 23, 2026
Merged

tina4stack merged 1 commit into
v3from
fix/frond-align-globals-v2

Conversation

@tina4stack

Copy link
Copy Markdown
Owner

Aligns Python/PHP/Ruby Frond globals to Node (ADR-0085, resolves tina4-documentation#90).

A bare reference to a zero-argument callable global is now invoked and its return
value drives both {{ g }} output and {% if g %} truthiness — previously
{% if admin_only %} with add_global("admin_only", () => ...) was always truthy
in Python/PHP/Ruby because the callable itself was stored. g() still works and
calls exactly once; a non-callable global, a callable that declares parameters, and
an unregistered nope() are all untouched.

The change wraps a qualifying zero-param global in a small marker at registration
(_CallableGlobal / FrondAutoGlobal / AutoGlobal); the bare-reference resolver
invokes it once. Node needs no marker (its resolver already auto-calls a function
member) and gains a guard test only.

Verified at HEAD, no mocks (real closures, real template source): 7/7 in all four
frameworks, each mutation-proven (disabling the auto-call turns the behaviour cases
red, restored → green). Shared fixture frond_globals_contract.json.

Re-applied onto current HEAD from the month-old fix/frond-align-globals branch.

🤖 Generated with Claude Code

…085)

A bare zero-argument callable global registered via add_global/addGlobal is now
invoked and its return value is used for both {{ g }} output and {% if g %}
conditions, matching Node (ADR-0004, resolving tina4-documentation#90). Explicit
g() still works and calls exactly once. Scope is globals only: ordinary context
variables, filters, macros and member access are unchanged, and an arg-taking
global is left as-is. The auto-call trigger is a bare zero-parameter
closure/lambda/proc; an arbitrary callable/__invoke/__call object is never
auto-called (F6/ADR-0077). Real in-memory tests, no mocks; red-first.

Co-Authored-By: Tina4 <82961293+tina4stack@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Andre van Zuydam <andrevanzuydam@gmail.com>
(cherry picked from commit 3eb3c80)
@tina4stack
tina4stack merged commit a593556 into v3 Oct 23, 2026
14 checks passed
@tina4stack
tina4stack deleted the fix/frond-align-globals-v2 branch October 23, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants