Text
Purpose
Section titled “Purpose”The Text Operator enables working with text and templates. It provides functionality for text manipulation, formatting, and template rendering, allowing for dynamic content generation and text transformation.
Use Cases
Section titled “Use Cases”- Generating dynamic content from templates
- Formatting text for display or processing
- Extracting specific parts of text
- Converting text between different formats
- Creating URL-friendly slugs from text
- Normalizing text input
- Manipulating text case (uppercase, lowercase, etc.)
- Finding and replacing text patterns
- Processing user input
- Preparing text for database storage
Supported Operations
Section titled “Supported Operations”render-template
Section titled “render-template”Renders a template with provided values using Mustache templating.
Input Parameters
Section titled “Input Parameters”template
(string): The template string with Mustache placeholdersvalues
(object): The values to use for template rendering
Output
Section titled “Output”Returns the rendered template as a string.
Example
Section titled “Example”{ "template": "Hello, {{name}}! Welcome to {{company}}.", "values": { "name": "John Doe", "company": "SyncMyOrders" }}
trim-and-normalize
Section titled “trim-and-normalize”Trims whitespace and normalizes text by removing extra spaces.
Input Parameters
Section titled “Input Parameters”text
(string): The text to trim and normalizeremoveExtraSpaces
(boolean, optional): Whether to replace multiple spaces with a single space
Output
Section titled “Output”Returns the trimmed and normalized text.
Example
Section titled “Example”{ "text": " This text has extra spaces. ", "removeExtraSpaces": true}
case-conversion
Section titled “case-conversion”Converts text to a different case format.
Input Parameters
Section titled “Input Parameters”text
(string): The text to convertconversion
(string): The type of conversion to perform (UPPER, LOWER, CAPITALIZE, TITLE_CASE)
Output
Section titled “Output”Returns the text in the specified case format.
Example
Section titled “Example”{ "text": "this is a sample text", "conversion": "TITLE_CASE"}
find-and-replace
Section titled “find-and-replace”Finds and replaces text patterns.
Input Parameters
Section titled “Input Parameters”text
(string): The text to processfind
(string): The text to findreplace
(string): The text to replace it withreplaceAll
(boolean, optional): Whether to replace all occurrences or just the first one
Output
Section titled “Output”Returns the text with replacements applied.
Example
Section titled “Example”{ "text": "The quick brown fox jumps over the lazy dog", "find": "fox", "replace": "cat", "replaceAll": true}
extract-first-line
Section titled “extract-first-line”Extracts the first line from text.
Input Parameters
Section titled “Input Parameters”text
(string): The text to processtrimResult
(boolean, optional): Whether to trim the result
Output
Section titled “Output”Returns the first line of the text.
Example
Section titled “Example”{ "text": "First line\nSecond line\nThird line", "trimResult": true}
extract-first-word
Section titled “extract-first-word”Extracts the first word from text.
Input Parameters
Section titled “Input Parameters”text
(string): The text to processtrimResult
(boolean, optional): Whether to trim the resultdelimiter
(string, optional): The delimiter to use for splitting words (default is space)
Output
Section titled “Output”Returns the first word of the text.
Example
Section titled “Example”{ "text": "First word second word third word", "trimResult": true, "delimiter": " "}
split-and-join
Section titled “split-and-join”Splits text by one delimiter and joins it with another.
Input Parameters
Section titled “Input Parameters”text
(string): The text to processsplitBy
(string): The delimiter to split byjoinWith
(string): The delimiter to join withtrimParts
(boolean, optional): Whether to trim each part before joining
Output
Section titled “Output”Returns the text split and rejoined with the specified delimiters.
Example
Section titled “Example”{ "text": "apple,orange,banana,grape", "splitBy": ",", "joinWith": " | ", "trimParts": true}
remove-characters
Section titled “remove-characters”Removes specified characters from text.
Input Parameters
Section titled “Input Parameters”text
(string): The text to processcharacters
(string): The characters to removeremoveSpaces
(boolean, optional): Whether to also remove spaces
Output
Section titled “Output”Returns the text with specified characters removed.
Example
Section titled “Example”{ "text": "Hello, World! 123", "characters": ",.!123", "removeSpaces": false}
substring-extraction
Section titled “substring-extraction”Extracts a substring from text.
Input Parameters
Section titled “Input Parameters”text
(string): The text to processstartIndex
(integer): The starting index (0-based)endIndex
(integer, optional): The ending index (exclusive)length
(integer, optional): The length of the substring to extract (alternative to endIndex)
Output
Section titled “Output”Returns the extracted substring.
Example
Section titled “Example”{ "text": "The quick brown fox jumps over the lazy dog", "startIndex": 4, "length": 5}
collapse-or-expand-lines
Section titled “collapse-or-expand-lines”Collapses multiple lines into one or expands a single line into multiple lines.
Input Parameters
Section titled “Input Parameters”text
(string): The text to processmode
(string): The mode to use (COLLAPSE or EXPAND)delimiter
(string): The delimiter to use for collapsing or expanding
Output
Section titled “Output”Returns the text with lines collapsed or expanded.
Example
Section titled “Example”{ "text": "Line 1\nLine 2\nLine 3", "mode": "COLLAPSE", "delimiter": " | "}
slugify
Section titled “slugify”Converts text to a URL-friendly slug.
Input Parameters
Section titled “Input Parameters”text
(string): The text to convert to a sluglowercase
(boolean, optional): Whether to convert the slug to lowercaseseparator
(string, optional): The separator to use between words (default is ”-“)
Output
Section titled “Output”Returns the slugified text.
Example
Section titled “Example”{ "text": "This is a Sample Title! 123", "lowercase": true, "separator": "-"}
- The Text Operator uses Mustache for template rendering
- Text operations are performed using Java’s string manipulation methods
- Case conversion supports various formats (UPPER, LOWER, CAPITALIZE, TITLE_CASE)
- The slugify operation removes special characters, replaces spaces with separators, and normalizes text
- All operations handle null or empty input gracefully
- The operator is useful for preparing text for display, storage, or further processing
- Template rendering can use complex objects with nested properties