MUJinjaRender
Real Jinja2 templating, minus the curly-brace fights
- STRING
ComfyUI's frontend already owns the {} characters for its own syntax, so you can't just drop a stock Jinja2 template into a node - the parser would choke on the very delimiters Jinja is built around. MUJinjaRender solves that by swapping in its own delimiters: {{ }} becomes <= =>, {% %} becomes <% %>, and {# #} becomes <# #>. Otherwise it's the real deal - a Jinja2 environment, running on your machine, taking a multiline text input and rendering it to a single STRING output.
You already know the shape of the use case even if you've never used Jinja: you want a string that isn't a constant. Build a prompt from computed values, generate a file path with a number baked in, construct a sequence of LoRA weights without typing ten of them. The node ships a decent math toolbox in its globals - pi, min, max, clamp(min, value, max), abs, round, ceil, floor, plus sqrt and the trig functions (which are rounded to two decimals, a quirk worth knowing if you're doing precision math). There's also datetime, and a steps(start, end, step=0.1) generator that yields inclusive steps - handy when you want a template rendered once per value in a range.
The most useful piece is the template(template, sequence, ...) function: it iterates a sequence, substituting $0, $1, etc. with each item, and concatenates the results. Feed it steps(), and you've got a compact way to emit a whole series. The README's example pattern - combining <= ... => expression blocks inside a loop with <% for x in steps(...) %> - is the sweet spot.
Two gotchas, and the first one will trip you up if you're Jinja-experienced: forget the {} syntax. Muscle memory writes {{ value }} and the node quietly fails to do what you meant. Second, on a template syntax error the node logs the failure and returns your text unchanged - so a broken template produces a silent wrong answer, not a crash. Check the ComfyUI console if output looks untouched.
Rendering is one-shot and stateless: each evaluation is a fresh environment, so you can't persist variables between renders the way you might in a server-side templating setup. That's fine for the graph, just don't expect memoization.
It's part of asagi4's minimal comfyui-utility-nodes collection - six nodes, and this one brings the jinja2 dependency with it. Install through ComfyUI Manager (search "comfyui-utility-nodes") or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/asagi4/comfyui-utility-nodes
cd comfyui-utility-nodes
pip install -r requirements.txt
Restart, find it under "misc-utils", and wire the STRING out into your CLIPTextEncode or any text input. It's not the node you need every day, but the day you need to generate forty sequential weights, you'll be glad the frontend's {} grip doesn't reach this far.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |