Skip to main content

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

PlatformOutput
iOSSwift: generates an enum with static properties for each event
AndroidKotlin: 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

VariableDescription
{{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}}
VariableDescription
{{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}}
VariableDescription
{{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

HelperDescription
{{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:

  1. Go to Settings → Code Generation
  2. Switch between iOS (Swift) and Android (Kotlin) tabs
  3. Edit the template (the preview updates in real time)
  4. Optionally change the output file name
  5. 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.