Inject Text

Node Icon

This node injects specified input text values into a target text at designated placeholder locations. Placeholders in the target text follow a specific format (e.g., {T0}, {T1}, etc.), with each corresponding to a unique input text value. This allows for dynamic text composition where specified portions of the text can be replaced based on external input.

Placeholder Format

Each placeholder is uniquely identified by a numeric suffix, allowing for multiple injections within a single target text.

Handling Backslashes

Backslashes (\) are not treated as escape characters in the context of placeholders. Instead, they are preserved as part of the text. If a placeholder follows a backslash (e.g., \{T0}), the backslash remains in the output, and the placeholder is replaced normally.

Example:


Escape Patterns

The node supports various brace patterns to handle literal placeholders or specific wrapping needs:

  1. Single Braces ({T0}):

    • Replaced with the corresponding input text.
    • Example: "Hello, {T0}""Hello, World" (if T0 = "World").
  2. Double Braces ({{T0}}):

    • Preserves the placeholder as a literal, wrapped in single braces.
    • Example: "Hello, {{T0}}""Hello, {T0}".
  3. Triple Braces ({{{T0}}}):

    • Replaces the placeholder and wraps the value in single braces.
    • Example: "Hello, {{{T0}}}""Hello, {World}" (if T0 = "World").
  4. Quadruple Braces or Higher:

    • For any odd number of braces, the placeholder is replaced, reducing by one level of braces.
    • For any even number of braces, the placeholder is preserved as a literal with half the braces.
    • Example:
      • "Hello, {{{{T0}}}}""Hello, {{World}}" (if T0 = "World")
      • "Hello, {{{{{T0}}}}}""Hello, {{{World}}}".

Usage Example

Target Text:
"Path: {T0}, Literal: {{T1}}, Triple: {{{T2}}}, Backslash: \{T3}"

Inputs:

Result:
"Path: File, Literal: {T1}, Triple: {Wrapped}, Backslash: \World"


Handling Literal Placeholders

Literal placeholders can be handled using the escape mechanisms described above. If a placeholder should remain in the target text without being replaced, ensure it is either:

  1. Double Curly Braces:

    • Example: {{T0}}{T0}
  2. Uneven Levels of Braces:

    • Example: Triple braces replace, quadruple preserve, and so on.

Inputs

T0

Input Text(s) to be injected. Dynamic input, i.e. if T0 is connected and you connect a new input to Append, the newly connected input will be denoted T1.

Type: Text, List, Required, Single

Outputs

Output

Output Text(s).

Type: Text, List

Settings

Target Text Text

Target text. At the placeholder, denoted by {TO}, {T1} etc, the input Text will be injected. E.g. if the target text is ‘my name is {T0}’ and the input text in T0 is ‘anna’, the output will be ‘my name is anna’. NB: The variable name, e.g. T0, is case sensitive.

See also

Keywords: