Nodes/Chaser's Custom Nodes/Register Template
ComfyUI Node

Register Template

Give a prompt template a name so the whole graph can use it

By chaserhkj·Created about a year ago·Updated 11 months ago· 0
Register Template
  • tmpl_dict
  • TMPL_DICT
template_name
template_source

Register Template is the naming service for this pack's templating system. It takes a template's text, gives it a name, and hands back a TMPL_DICT - a dict of named templates you can thread through the graph and feed to Prompt Template or Load Template File.

Two required inputs: template_name, a plain string you type, and template_source, the multiline template body. Optionally, an existing tmpl_dict input lets you append to (and override entries in) a dict that's already flowing through the graph. The mechanism is dead simple - copy the incoming dict (or start empty), then result[template_name] = template_source - so the last registration of a given name wins.

Why this matters. Templates in this pack can reference each other. Prompt Template builds its Jinja environment with a DictLoader when you pass it a tmpl_dict, which means one template can pull in another by name - think a shared negative-prompt block, or a style snippet that several prompts include. Register Template is how you make those names exist. Instead of pasting your negative prompt into every template, you register it once and reference it everywhere.

# conceptually what you're doing:
#   templates["shared_negative"] = "..."
# then a PromptTemplate can {% include 'shared_negative' %}

What to watch out for:

  • Names are exact and unforgiving. Misspell shared_negative in one node and the include silently renders as empty or errors at render time. The pack won't warn you.
  • It's in-memory only. The registered dict lives for the duration of the run and dies with the graph. Nothing persists across restarts, so the registration chain has to exist in every workflow that uses it.
  • template_name is forced-input style in the schema, so you'll usually feed it from a text node rather than typing into a fixed field - fine, just wire it.
  • The output TMPL_DICT is the thing to connect to Prompt Template's tmpl_dict input, or to chain into another Register Template to grow the dict.

Install is the pack standard (Chaser's Custom Nodes, chaserhkj). ComfyUI Manager - search "Chaser's Custom Nodes" - or:

cd ComfyUI/custom_nodes
git clone https://github.com/chaserhkj/ComfyUI-Chaser-nodes

then restart. No models to fetch; jinja2, pyyaml, requests, sexpdata, and av install automatically. The README calls these ad-hoc personal nodes and warns "use them at your own risk" - for a node that just stuffs strings into a dict, that risk is low, but keep it in mind when you start building whole workflows on top of it.

CategoryChaser Custom Nodes

Inputs (3)

NameTypeDefaultDescription
template_nameSTRING
template_sourceSTRING
tmpl_dictoptTMPL_DICT

Outputs (1)

NameTypeDescription
TMPL_DICTTMPL_DICT