>mir

Template Syntax

// Handlebars template engine for dynamic file generation

Basic Variables

Use double braces to insert variables into file names and content.

// snippet.yaml
variables:
  name:
    schema:
      type: string
      default: "myFunction"
  author:
    schema:
      type: string
// template
// File: {{ name }}.ts
// Author: {{ author }}
export function {{ name }}() {
  // implementation here
}

Conditionals

Use #if...#endif blocks for conditional content.

// template
{{#if typescript}}
interface Props {
  {{#each fields}}
  {{this}}: string;
  {{/each}}
}
{{/if}}

Lists

Use #each...#end to iterate over arrays.

// template
{{#each imports}}
import {{ this }} from '{{ this }}';
{{/each}}

Built-in Variables

The following variables are always available:

project-name

Name from package.json or directory name