LogoCyanPrint

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 processor
files: [{ root: 'templates', glob: '**/*', exclude: [], type: GlobType.Template }],
config: {
// Processor-specific configuration
delimiters: ['{{', '}}'],
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 templates
vars: {
name: 'my-project',
version: '1.0.0'
},
// Processor-specific options
options: {
strict: true,
formatOutput: true
}
}
}

Available Processors

ProcessorPurposeTemplate Syntax
cyan/defaultEta templatingvar__name__
CustomAny engineDepends 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:

  1. Create a processor package
  2. Implement the processor interface
  3. Publish to a registry
  4. Reference in your templates

See Processor Development for detailed instructions.