Skip to main content

šŸ”„ 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"
tip

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.