š Simple Transform Plugin
The Simple Transform plugin enables string-based transformations using Mustache templates. Unlike the Object Transform plugin which outputs an object, this plugin outputs a formatted string. It's particularly useful for formatting messages before sending them to chat platforms.
š Featuresā
- String Output: Transform input data into a formatted text string
- Template-based Formatting: Use Mustache templates to format content
- Section Support: Use Mustache sections for conditional content
š Usageā
The plugin accepts a configuration with a template string that defines how to format the output:
{
"plugin": "@curatedotfun/simple-transform",
"config": {
"template": "Your template string here"
}
}
šØ Mustache Template Syntaxā
Basic Variablesā
Use double curly braces to insert a value:
Hello {{username}}!
If username
is "Alice", outputs: Hello Alice!
Optional Sectionsā
Use #
to start a section and /
to end it. The section is only rendered if the value exists and is not empty:
{{#curator.notes}}
š Note: {{.}}
{{/curator.notes}}
- If
curator.notes
is "Great thread!", outputs:š Note: Great thread!
- If
curator.notes
is empty or missing, outputs nothing
Inverted Sectionsā
Use ^
for sections that render only when a value is missing or empty:
{{^curator.notes}}
No curator notes provided
{{/curator.notes}}
Only renders "No curator notes provided" if curator.notes
is empty or missing
Nested Valuesā
Access nested object properties using dot notation:
Posted by {{user.profile.name}} (@{{user.handle}})
Lists/Arraysā
Iterate over arrays using sections:
Tags:
{{#tags}}
- {{.}}
{{/tags}}
If tags
is ["crypto", "defi"]
, outputs:
Tags:
- crypto
- defi
š” Examplesā
Basic String Formatā
{
"plugin": "@curatedotfun/simple-transform",
"config": {
"template": "š„ {{content}}\n\n{{#curator.notes}}š {{.}}{{/curator.notes}}\n\nš Source: https://x.com/{{username}}/status/{{submissionId}}\n"
}
}
Given this input:
{
"content": "Just launched our new DeFi protocol!",
"username": "cryptobuilder",
"submissionId": "123456789",
"curator": {
"notes": "Interesting launch with novel tokenomics"
}
}
Outputs:
š„ Just launched our new DeFi protocol!
š Interesting launch with novel tokenomics
š Source: https://x.com/cryptobuilder/status/123456789
Rich Format with Conditionalsā
{
"plugin": "@curatedotfun/simple-transform",
"config": {
"template": "{{#title}}š¢ {{.}}\n\n{{/title}}{{content}}\n\n{{#links}}š {{.}}\n{{/links}}\n{{#curator.notes}}š Curator's Note: {{.}}{{/curator.notes}}\n\n{{^curator.notes}}ā” Auto-curated{{/curator.notes}}"
}
}
This template:
- Shows a title section if present
- Always shows the content
- Lists all links if any exist
- Shows curator notes if present, otherwise shows "Auto-curated"
Use this plugin when you need to format data into a text string. If you need to transform data structures between plugins, use the Object Transform plugin instead.