Nodes/ComfyUI-QING/文本拼接丨V2
ComfyUI Node

文本拼接丨V2

Fill {var1}..{var8} placeholders in a prompt template

By sheengoa·Created about a year ago·Updated 20 days ago· 16
文本拼接丨V2
    • 结果文本
    • 缺失变量
    • 调试信息
    template
    var1
    var2
    var3
    var4
    var5
    var6
    var7
    var8

    Structured prompts are the boring kind of power. You've got a formula - subject, pose, lighting, background - and you want to swap the variables without retyping the whole sentence every time. QING_PromptTemplate is the QING pack's text-slot filler: write a template with {var1} through {var8} placeholders, feed the values in, get the assembled text out. This is the "V2" version of the pack's text templating, and the placeholder syntax matters (see below).

    What it does

    template is the multiline text with up to eight placeholders. var1var8 are the replacement strings. The node renders the template, substituting each placeholder with its variable - and here's the genuinely friendly bit: empty variables don't error. An empty {var3} just renders as an empty string, so a template with optional slots works without you having to wire up "only fill this when it exists" logic.

    Outputs: 结果文本 (the rendered string), 缺失变量 (a CSV of which placeholders were left empty - so you can know when something didn't get filled), and a debug string with placeholder counts and replacement stats.

    The V2 trap

    The pack has two template nodes and their syntax is different: the older TextTemplateConcat ("文本拼接") uses {text1} through {text5}, while this one - QING_PromptTemplate, "文本拼接丨V2" - uses {var1} through {var8}. If you copy a template between them, {text1} won't render here. Both follow the "template as a message" pattern from the prompt-engineering doc - the LLM-era encoders read assembled text, so slot-filling works for any checkpoint's prompt box, tags or sentences.

    Where you'd reach for it

    Any structured, repeatable prompt: keep the skeleton as the template, and wire var1var8 from whatever's driving the variation - a QING_PromptRandomizer roll, a batch item, a text list, a shared variable node. It's also the cheap way to build filename templates and log strings, since it's just text substitution. Output plugs straight into a CLIP Text Encode or an API node's text input.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/GAO-SHIQING/ComfyUI-QING
    cd ComfyUI-QING
    python install_dependencies.py
    

    Restart ComfyUI after. Pure regex-based substitution, zero dependencies. Manager: search "ComfyUI-QING." (README's GAOSHI-QING clone-URL typo - repo is GAO-SHIQING/ComfyUI-QING.)

    Things to know

    The regex that finds placeholders matches {word} patterns, so a stray literal {braces} in your template will be picked up as a placeholder (and reported as missing when empty) - it renders as blank, not as the literal text. If you need literal braces, know that going in. And the missing-variable output is your friend: when a generated prompt looks incomplete, that CSV tells you exactly which slot was empty instead of making you eyeball the string. One more: it replaces all occurrences of a placeholder, so reusing {var1} twice in one template works fine.

    CategoryQING/数据工具

    Inputs (9)

    NameTypeDefaultDescription
    templateSTRING模板文本,支持 {var1}~{var8}
    var1STRING
    var2STRING
    var3STRING
    var4STRING
    var5STRING
    var6STRING
    var7STRING
    var8STRING

    Outputs (3)

    NameTypeDescription
    结果文本STRING
    缺失变量STRING
    调试信息STRING