Repository navigation
fix(frond): zero-arg callable globals auto-call (ADR-0085) - #251
Merged
Merged
Conversation
…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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 %}withadd_global("admin_only", () => ...)was always truthyin Python/PHP/Ruby because the callable itself was stored.
g()still works andcalls 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 resolverinvokes 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-globalsbranch.🤖 Generated with Claude Code