Nodes/Skoogeer-Noise/Merge Mustache Variable Defs
ComfyUI Node

Merge Mustache Variable Defs

Combine two candidate pools before sampling

By ttulttul·Created 9 months ago·Updated 3 months ago· 14
Merge Mustache Variable Defs
  • variable_defs_1
  • variable_defs_2
  • variable_defs
conflict_modekeep_first

The mustache pipeline has two distinct data shapes, and confusing them is the #1 way people trip on this pack. There are definitions (MUSTACHE_VARIABLES - the pools of candidate values) and there are concrete sets (MUSTACHE_VARIABLE_LIST - one resolved assignment per prompt). This node merges definitions. It takes two MUSTACHE_VARIABLES mappings and combines them into one, so you can build your candidate pools from separate branches of the graph and feed the combined result to Mustache Variable Sampler in one shot.

Why two branches? Modularity. Maybe one branch of your workflow generates a "subject" pool (from a list node or a Mustache Variable), and another defines a fixed "setting" pool, and you don't want to hand-maintain one giant YAML. Merge the defs, then sample. That's the whole job.

The inputs and conflict handling

  • variable_defs_1 and variable_defs_2 - the two definition mappings.
  • conflict_mode - what happens when both sides define the same variable name:
    • keep_first (default) - keep the first mapping's value list, ignore the second's duplicate.
    • keep_second - overwrite with the second mapping's definition.
    • merge_values - append the candidate values from the second mapping after the first's, so the pool grows.

Output: variable_defs, one merged MUSTACHE_VARIABLES mapping.

One caveat on merge_values: it follows the same duplicate-key semantics as multi-input Mustache Variables - plain value lists append in order, but conflicting weighted definitions (values with :probability tags) still raise an error rather than guessing how to combine odds. So if you're merging two weighted pools with a shared variable name, resolve the weights yourself before merging.

Installing and using it

Part of Skoogeer-Noise. ComfyUI Manager → search "Skoogeer-Noise", or:

cd ComfyUI/custom_nodes
git clone https://github.com/ttulttul/Skoogeer-Noise

Restart ComfyUI. No models or keys; deps are torch, numpy, einops, pyyaml.

The trap

The trap is using this when you already have MUSTACHE_VARIABLE_LIST outputs. If both of your branches are already sampled concrete sets (say, one produced by Mustache Variable Set and another by a sampler), this node's inputs won't even accept them - and even if you force it, merging definitions after sampling is meaningless. That's what Merge Mustache Variable Sets is for: it merges concrete lists entry-by-entry so a downstream template sees both branches' keys in the same rendered prompt. Rule of thumb: merging before the sampler → this node; merging after → the other one. Knowing which is which is half of mastering this pack's templating family.

Categorytext/template

Inputs (3)

NameTypeDefaultDescription
variable_defs_1MUSTACHE_VARIABLESFirst mustache variable definition mapping to merge.
variable_defs_2MUSTACHE_VARIABLESSecond mustache variable definition mapping to merge.
conflict_modeCOMBOkeep_firstHow to handle duplicate variable names. keep_first preserves the first input, keep_second overwrites with the second input, and merge_values appends the candidate lists.

Outputs (1)

NameTypeDescription
variable_defsMUSTACHE_VARIABLES