Default Processor
How the cyan/default processor works with Eta templating
Default Processor
The cyan/default processor uses Eta templating with custom delimiters for variable substitution.
Overview
The default processor is the most commonly used processor. It:
- Replaces variable placeholders with values
- Supports nested variable access
- Allows custom delimiters
- Handles all text file types
Variable Syntax
Default Delimiters
The default syntax uses var__ prefix and __ suffix:
var__name__var__project.version__
Example
Template file:
# var__name__Welcome to var__name__!Author: var__author__Version: var__version__
With config:
processor:name: cyan/defaultfiles:- '**/*'config:vars:name: 'my-project'author: 'John Doe'version: '1.0.0'
Generated output:
# my-projectWelcome to my-project!Author: John DoeVersion: 1.0.0
Nested Variables
Access nested properties with dot notation:
processor:name: cyan/defaultfiles:- '**/*'config:vars:project:name: 'my-project'version: '1.0.0'
Template:
Project: var__project.name__Version: var__project.version__
Custom Delimiters
Change the delimiters for compatibility with other template syntaxes:
Using Angle Brackets
processor:name: cyan/defaultfiles:- '**/*'config:vars:name: 'my-project'parser:varSyntax:- ['<%', '%>']
Template:
# <% name %>
Using Mustache Style
processor:name: cyan/defaultfiles:- '**/*'config:vars:name: 'my-project'parser:varSyntax:- ['{{', '}}']
Template:
# {{ name }}
Using Double Braces
processor:name: cyan/defaultfiles:- '**/*'config:vars:name: 'my-project'parser:varSyntax:- ['${{', '}}']
Template:
# ${{ name }}
Why var__ Syntax?
The var__name__ syntax is chosen to avoid conflicts:
| Syntax | Potential Conflicts |
|---|---|
${name} | JavaScript template literals |
{{name}} | Handlebars, Mustache |
<%= name %> | EJS |
{name} | JSON, YAML |
var__name__ | Rarely used in any language |
The var__ prefix is verbose but ensures templates work correctly even when generating code that uses other template syntaxes.
Eta Features
The default processor is built on Eta, which supports more than simple substitution:
Conditionals
<% if (typescript) { %>## TypeScript ConfigurationThis project uses TypeScript.<% } %>
Note: This requires changing delimiters to avoid var__.
Loops
## Features<% features.forEach(function(feature) { %>- <%= feature %><% }) %>
Advanced Eta features like conditionals and loops require custom delimiters and may need adjustments to work correctly with the default processor's configuration. For complex templating needs, consider creating a custom processor.
Processor Configuration
The default processor supports the following configuration options:
processor:name: cyan/defaultfiles:- '**/*'config:# Variables to substitutevars:name: 'my-project'version: '1.0.0'# Parser configurationparser:# Custom tag pairs (default is ['var__', '__'])varSyntax:- ['var__', '__']
The cyan/default processor is a specific implementation provided as the reference processor. Other registries or organizations may provide their own default processors with different capabilities. Options like autoEscape, autoTrim, and filters are hardcoded in the processor implementation and cannot be configured by template authors.
When to Use Default vs Custom
Use Default When
- Standard variable substitution is sufficient
- Working with common file formats
- No special processing needed
Use Custom When
- Need different template engine (Handlebars, Mustache)
- Complex code generation required
- Special file transformations needed
See Processors vs Plugins for more guidance.
Related
- Tutorial: Adding Variables - Variable basics
- Processors vs Plugins - When to use each
- Use Custom Processor - Using custom processors