Nodes/ComfyUI-CustomNodePacks/Text Template (C2C)
ComfyUI Node

Text Template (C2C)

TextTemplateMEC for per-shot variables

By Code2Collapse·Created 6 months ago·Updated a day ago· 52
Text Template (C2C)
    • text
    templatea {a} of {b}, {c}, {d}
    a
    b
    c
    d

    The problem is prompts that are 90% identical. You're generating a shot where only the subject changes - "a {a} of {b}, {c}, {d}" - and you'd rather edit one template than re-type the whole sentence per image. TextTemplateMEC is the node that does the substitution for you: type a template once, feed four string variables, get a finished prompt out.

    It's a five-minute node from ComfyUI-CustomNodePacks (the MEC pack), and it sits right next to the pack's Shot Metadata Reader for a reason: those two form a tidy little batch-pipeline - read per-shot values from a JSON descriptor, then slot them into a prompt template. No model, no VRAM, nothing to install beyond the pack itself.

    How it works

    There's nothing clever here, and that's the point. You write a template with {a}, {b}, {c}, and {d} placeholders, and the node does a plain string substitution of the four ad inputs into those slots, returning the result as text. The default template is even a self-demonstrating a {a} of {b}, {c}, {d}.

    Four slots might feel limiting if you've used Jinja-style prompt tools, but it's deliberate: {a}, {b}, {c}, {d} are exactly the variables the sibling Shot Metadata Reader surfaces as its main show/shot/task outputs, so the two nodes slot together without any mapping ceremony.

    The inputs and outputs that matter

    All five inputs are plain strings:

    • template (multiline) - your prompt with {a}{d} placeholders.
    • a, b, c, d - the values to substitute. Leave one empty and that slot just comes out empty.

    The single output:

    • text (STRING) - the completed template. Wire it into a CLIP Text Encode, a prompt scheduler, or anywhere else a string is expected.

    Where it fits

    The real payoff is when the values aren't typed by hand - they come from another node. In the MEC pack's pipeline you'd read a shot.json, pull show/shot/task out of the metadata reader, and feed them into the template so each queued prompt is already personalized for the shot. That turns a manual copy-paste chore into a repeatable graph.

    One honest limitation: it's a single-shot substitution, not a mini templating language. If you need conditionals, loops, or a tenth variable, reach for something heavier. For "same sentence, different nouns per shot," this is the smallest thing that works.

    Installing it

    Install the whole pack once:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git
    

    then restart ComfyUI - or use ComfyUI Manager and search "CustomNodePacks". Confirm the pack loaded with the [MEC] Loading MaskEditControl node pack … console line. No extra dependencies for this node; skip the pack's requirements.txt unless you actually need the mask/VAE nodes, since a blind pip install -r can overwrite ComfyUI's bundled torch/numpy.

    Bottom line

    If you've been rebuilding prompts with string-concat nodes or just retyping them per shot, this is the cleaner option. It's boring, it's small, and it's exactly what "fill in the blanks" should be.

    CategoryC2C/Helpers

    Inputs (5)

    NameTypeDefaultDescription
    templateSTRINGa {a} of {b}, {c}, {d}
    aSTRING
    bSTRING
    cSTRING
    dSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING