Nodes/comfyui-darkil-nodes/Advanced variable builder [darkilNodes]
ComfyUI Node

Advanced variable builder [darkilNodes]

Multiline templates with real logic

By pytraveler·Created 7 months ago·Updated 16 days ago· 9
Advanced variable builder [darkilNodes]
  • INPUT_VAR
  • VAR
  • ❓help
switchtrue
out_val_by_switchtrue
var_namevariable_name
var_text

The plain Variable builder in this pack is a tidy single-line text helper. This is the version you reach for when the template stops fitting on one line: var_text is a full multiline editor, the placeholder language gains boolean expressions (&&, ||), quoted literals, and random variants, and dynamic input slots can feed in extra variables from elsewhere in the graph. Same family, properly grown up.

The inputs

  • switch (BOOLEAN, default true) - master enable.
  • out_val_by_switch (BOOLEAN, default true) - when on and switch is off, the value output goes empty (only help text remains). Note the default here is the opposite of the plain builder's - check it before wiring.
  • var_name (STRING) - prepends name = to the result; leave blank for the raw value.
  • var_text (STRING, multiline) - the template.
  • INPUT_VAR (optional) - name=value lines that define variables; the last line without an = is treated as the "default" value.

The node also grows dynamic input slots at runtime (DYNAMIC_1, DYNAMIC_2, …) so other nodes can inject variables on the fly - that's how you build a prompt fragment in one place and reference it here.

The placeholder language

Everything the plain builder does, plus:

  • {{"literal"}} - insert a literal string; quotes optional.
  • {{var}} / {{DATE}} / {{TIME}} - variable references and the date/time shortcuts, same as the small one.
  • {{IF:cond:true:false}} and {{IFNOT:cond:true:false}} - conditionals whose cond supports && and || over booleans or other variables.
  • {{var??default}} - fallback when var is empty.
  • Special names default, def, _ resolve to the default single-line value.
  • |-separated variable values pick a random variant each run.
  • Comments (# …) are stripped; cyclic references resolve to empty with a warning.

So var_text of Hello {{user}}! Today is {{DATE}}. with INPUT_VAR = user = Alice produces variable_name = Hello Alice! Today is 20260816 - that's the author's own worked example, and it's a fair sense of the power level.

The outputs

  • VAR (STRING) - the assembled name = value or raw value.
  • ❓help (STRING) - the node's documentation on a socket, like every node in this pack.

Where people get burned

The out_val_by_switch default flip catches people migrating from the plain builder. And the expression parser is deliberately compact - complex nested logic is better handled by composing a few of these nodes than by one monster template, because the failure mode (a placeholder that resolves to empty) is quiet and can be hard to trace. Build up, test small.

Installing

Ships in pytraveler/comfyui-darkil-nodes. ComfyUI Manager search ComfyUI-darkil-nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/pytraveler/comfyui-darkil-nodes

Restart. No Python deps or models.

CategorydarkilNodes/text

Inputs (5)

NameTypeDefaultDescription
switchBOOLEANtrue
out_val_by_switchBOOLEANtrue
var_nameSTRINGvariable_name
var_textSTRING
INPUT_VARoptBOOLEAN,INT,FLOAT,STRING,COMBO

Outputs (2)

NameTypeDescription
VARSTRING
❓helpSTRING