Files
masslevel-ComfyUI-masslevel…/README.md
T

108 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ComfyUI-masslevel-TextProcessing
Text processing utilities for ComfyUI by [masslevel](https://github.com/masslevel).
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![Variable Text Processor example workflow](example_workflows/ComfyUI-masslevel-TextProcessing-example_workflow.png)
---
## Nodes
### Variable Text Processor (masslevel)
Processes a multiline text template by replacing `{variable_name}` placeholders with dynamically wired input values. Pins can be added, removed, and renamed at any time — the pin name is the variable name.
**Category:** `masslevel/Text`
---
## Installation
Clone or download this repository into your `ComfyUI/custom_nodes/` directory:
```bash
cd ComfyUI/custom_nodes
git clone https://github.com/masslevel/ComfyUI-masslevel-TextProcessing
```
Restart ComfyUI.
---
## Variable Text Processor — Usage
### Basic concept
Write a template with `{placeholder}` tokens, wire any value into a named pin, and the node outputs the fully resolved string.
```
Template:
resolution: {video_width}x{video_height}
fps: {video_fps}
model: {model_name}
cfg: {sampler_cfg}
Wired:
video_width → 1920
video_height → 1080
video_fps → 25
model_name → "model.safetensors"
sampler_cfg → 25.0
Output:
resolution: 1920x1080
fps: 25
model: model.safetensors
cfg: 25.0
```
### Adding variables
Click the **+ Add Variable** button on the node body. A prompt will ask for a name — use letters, numbers, and underscores only (e.g. `fps`, `model_name`, `subject`). The name becomes the `{placeholder}` token in your template.
### Removing variables
Right-click the node body → **Remove Variable Pin** → select the variable to remove. Any connected wire is cleanly disconnected first.
### Renaming variables
Two methods — both keep the connected wire in place:
- **Context menu:** Right-click the node body → **Rename Variable Pin** → select the variable and enter a new name.
- **Native rename:** Right-click the connection point on the pin → **Rename Slot** → enter a new name.
### Inputs
| Input | Type | Description |
|---|---|---|
| `template` | STRING (multiline) | The template text containing `{placeholder}` tokens. Can be typed directly or wired from an external multiline string node. |
| *(dynamic)* | STRING / INT / FLOAT | One pin per variable. The pin name must match the `{placeholder}` in the template exactly. INT and FLOAT values are automatically converted to string. |
### Output
| Output | Type | Description |
|---|---|---|
| `text` | STRING | The fully resolved template. Unmatched `{placeholders}` with no connected pin are passed through unchanged. |
### Notes
- Variable names and their order persist across workflow save and reload.
- Unresolved placeholders are passed through unchanged — they will not error.
- The template field itself can be wired from an external multiline text node.
---
## Compatibility
- ComfyUI (latest)
- Python 3.10+
- No additional dependencies required
---
## License
MIT