Support references in std::template
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 0
- Forks
- 6
- Avg merge
- 12h 25m
- Merged PRs (30d)
- 5
Description
Context
The future module has a reference-aware jinja plugin (inmanta_plugins/future/std/__init__.py): when a reference ends up as a terminal value in a template, it is registered and replaced by a placeholder, and the plugin returns a JinjaReference (a Reference[str]) that finishes the render agent-side once the reference values are known. Everything that can be rendered at compile time is rendered at compile time.
It should move into std::template. Today it only works by monkeypatching core and std at render time (monkeypatch.py).
Discussion: Slack thread.
Blocked on inmanta/inmanta-core#10693, which covers the two core-side patches: allowing reference values through DynamicProxy for the duration of a render, and a supported interception point for a reference reaching a terminal position.
Scope of this ticket (std side)
-
JinjaDynamicProxy.return_value— the std counterpart of the core proxy change: during a render, a reference reached through the jinja proxy must be passed through instead of rejected.futurepatches it to skip the reference guard; once core offers the supported mechanism,JinjaDynamicProxyshould use it natively (scoped to the render, reverted on every exit path, including theUnsetException/MultiUnsetExceptioncontrol flow). -
Rendering the placeholder — core provides the hook that fires when a reference is stringified; std decides what to emit. In
futurethat is{% endraw %}{{ references["<id>"] }}{% raw %}, with the reference stored in a render-local context. Notestd::FactReferencedefines its own__str__, so it currently has to be registered by hand — whatever hook core lands on, std's own reference classes must route through it. -
JinjaReference— aReference[str]holding the partially rendered template plus the map of registered references, resolving them agent-side and rendering the remainder. Needs a home in std, a stable serialization name, and handler-side tests. -
std::templatebehaviour — no references in the render ⇒ return the plain string exactly as today; references present ⇒ return aJinjaReference. Backwards compatibility of a plugin declared-> stringreturning a reference is part of the core discussion. -
preview-style introspection —futureships apreviewplugin to inspect an unresolved value (plain string as-is, unresolved template for aJinjaReference,reprotherwise) without forcing resolution. Worth taking along, since error messages and model-side debugging otherwise show an opaque reference.
Definition of done
std::templatesupports references without patching core or std internals.- The template part of
future::stdcan be dropped in favour of std.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with inmanta_plugins/future/std/init.py and monkeypatch.py to understand the existing reference-aware Jinja behavior, then review the core dependency in inmanta-core#10693. Trace JinjaDynamicProxy.return_value, JinjaReference, and the preview plugin, including handler-side tests. Done means std::template works without monkeypatching, preserves plain strings, and resolves reference-bearing templates agent-side.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100