Use a Custom Processor
How to use custom processors in your templates
How to Use a Custom Processor
Use custom processors for advanced file processing beyond the default Eta templating.
What is a Processor?
Processors handle file transformation. The default processor (cyan/default) uses Eta templating with var__name__ syntax. Custom processors can:
- Use different template engines (Mustache, Handlebars, EJS)
- Perform code transformations (AST manipulation)
- Generate files programmatically
- Run custom build steps
Using a Custom Processor
In Template Configuration
Specify the processor name:
return {processors: [{name: 'myorg/mustache-processor', // Custom processorfiles: [{ root: 'templates', glob: '**/*', exclude: [], type: GlobType.Template }],config: {// Processor-specific configurationdelimiters: ['{{', '}}'],escapeDelimiter: '{{{'}}]};
Multiple Processors
Combine multiple processors for different file types:
return {processors: [// Default processor for most files{name: 'cyan/default',files: [{ root: 'templates', glob: '**/*.md', exclude: [], type: GlobType.Template },{ root: 'templates', glob: '**/*.json', exclude: [], type: GlobType.Template }],config: { vars: { name: 'my-project' } }},// Custom processor for special files{name: 'myorg/codegen-processor',files: [{ root: 'templates', glob: '**/*.graphql', exclude: [], type: GlobType.Template }],config: {generateTypes: true,outputDir: 'src/generated'}}]};
Processor Configuration
Pass configuration to your processor:
{name: 'myorg/custom-processor',files: [/* ... */],config: {// Variables to use in templatesvars: {name: 'my-project',version: '1.0.0'},// Processor-specific optionsoptions: {strict: true,formatOutput: true}}}
Available Processors
| Processor | Purpose | Template Syntax |
|---|---|---|
cyan/default | Eta templating | var__name__ |
| Custom | Any engine | Depends on implementation |
See Processor Development for creating your own processors.
Example: Handlebars Processor
return {processors: [{name: 'myorg/handlebars-processor',files: [{ root: 'templates', glob: '**/*.hbs', exclude: [], type: GlobType.Template }],config: {vars: {name: 'my-project',features: ['auth', 'api', 'ui']},helpers: {uppercase: (str) => str.toUpperCase(),capitalize: (str) => str.charAt(0).toUpperCase() + str.slice(1)}}}]};
Template file with Handlebars syntax:
# {{name}}## Features{{#each features}}- {{capitalize this}}{{/each}}
Example: Code Generation Processor
return {processors: [{name: 'myorg/prisma-processor',files: [{ root: 'schema', glob: '**/*.prisma', exclude: [], type: GlobType.Template }],config: {generateClient: true,outputDir: 'src/db',previewFeatures: ['fullTextSearch']}}]};
Creating Custom Processors
If you need specialized processing:
- Create a processor package
- Implement the processor interface
- Publish to a registry
- Reference in your templates
See Processor Development for detailed instructions.
Related
- Processor Development - Create custom processors
- Default Processor - How cyan/default works
- Processors vs Plugins - When to use each