Code Generation
Ordaze generates type-safe Swift and Kotlin files from your event registry using customizable Handlebars templates. Download generated files via the API or configure templates in Settings.
Supported Platforms
| Platform | Output |
|---|---|
| iOS | Swift: generates an enum with static properties for each event |
| Android | Kotlin: generates a sealed class or object per event category |
Each platform has a default template. You can customize templates per workspace in Settings → Code Generation.
Template System
Handlebars
Templates use Handlebars syntax. Write your template in the built-in editor with live preview and validation.
Context Variables
| Variable | Description |
|---|---|
| {{today}} | Current date (YYYY-MM-DD) |
| {{eventCount}} | Total number of events |
| {{categories}} | Array of destination names |
| {{allProperties}} | Array of all property names across events |
Iterating Events
{{#each eventsByCategory}}
// Category: {{category}}
{{#each events}}
// Event: {{name}} ({{camelCase}}, {{pascalCase}})
// {{description}}
{{#if deprecated}}// @deprecated{{/if}}
{{/each}}
{{/each}}| Variable | Description |
|---|---|
| {{category}} | Destination name |
| {{name}} | Event name in snake_case |
| {{camelCase}} | Event name in camelCase |
| {{pascalCase}} | Event name in PascalCase |
| {{description}} | Event description text |
| {{deprecated}} | Boolean, true if event is deprecated |
| {{hasProperties}} | Boolean, true if event has properties |
Property Fields
{{#each properties}}
{{name}}: {{swiftOptionalType}} // {{camelCase}}, {{upperSnake}}
{{/each}}| Variable | Description |
|---|---|
| {{name}} | Property name in snake_case |
| {{camelCase}} | Property name in camelCase |
| {{upperSnake}} | Property name in UPPER_SNAKE_CASE |
| {{swiftOptionalType}} | Swift type with optional marker (e.g. String?) |
| {{kotlinOptionalType}} | Kotlin type with nullable marker (e.g. String?) |
| {{required}} | Boolean, true if property is required |
Helper Functions
| Helper | Description |
|---|---|
| {{toCamelCase name}} | Convert to camelCase |
| {{toPascalCase name}} | Convert to PascalCase |
| {{toUpperSnakeCase name}} | Convert to UPPER_SNAKE_CASE |
| {{swiftType type required}} | Map to Swift type (String, Int, Bool, etc.) |
| {{kotlinType type required}} | Map to Kotlin type (String, Int, Boolean, etc.) |
| {{#if (eq status "deprecated")}} | Equality comparison helper |
| {{#if (hasItems properties)}} | Check if array has items |
| {{@first}} / {{@last}} | Loop boundary checks |
| {{@index}} | Current loop index (0-based) |
Full Example
Complete Swift Template
A working template that generates a Swift file with typed event enums. Copy this as a starting point for your own template.
// Auto-generated by Ordaze on {{today}}
// {{eventCount}} events across {{categories.length}} destinations
import Foundation
{{#each eventsByCategory}}
// MARK: - {{category}}
enum {{toPascalCase category}}Events: String {
{{#each events}}
/// {{description}}
{{#if deprecated}}@available(*, deprecated, message: "Use replacement event")
{{/if}}case {{camelCase}} = "{{name}}"
{{/each}}
}
{{#each events}}
{{#if hasProperties}}
struct {{pascalCase}}Properties {
{{#each properties}}
let {{camelCase}}: {{swiftOptionalType}}
{{/each}}
}
{{/if}}
{{/each}}
{{/each}}Custom Templates
Each workspace has default Swift and Kotlin templates. To customize:
- Go to Settings → Code Generation
- Switch between iOS (Swift) and Android (Kotlin) tabs
- Edit the template (the preview updates in real time)
- Optionally change the output file name
- Save when ready, or reset to restore the default
The editor supports Tab for indentation and Ctrl/Cmd+S to save. Template validation runs on every change.