Handlebars Reference
Complete reference for Handlebars syntax and available template variables in Ralph TUI.
Handlebars Basics
Ralph uses Handlebars for template rendering. Handlebars is a logic-less templating language that uses double curly braces for variable substitution.
Variable Substitution
Insert variable values with \{\{variableName\}\}:
Renders to:
Conditional Blocks
Show content only when a variable has a value:
The block renders only if taskDescription is non-empty.
Else Blocks
Provide fallback content:
Unless Blocks
Inverse of if - renders when value is falsy:
Comments
Add template comments that won't appear in output:
Available Variables
Ralph provides these variables for template rendering:
Task Information
| Variable | Type | Description |
|---|---|---|
taskId | string | Unique task identifier (e.g., "US-001", "beads-abc") |
taskTitle | string | Task title/summary |
taskDescription | string | Full task description |
acceptanceCriteria | string | Extracted acceptance criteria (formatted as checklist) |
type | string | Task type: "feature", "bug", "task", etc. |
status | string | Current status: "open", "in_progress", "closed" |
priority | string | Priority level: "0" (critical) to "4" (backlog) |
notes | string | Additional task notes or context |
Relationships
| Variable | Type | Description |
|---|---|---|
dependsOn | string | Comma-separated list of dependency task IDs |
blocks | string | Comma-separated list of tasks this blocks |
labels | string | Comma-separated list of labels |
epicId | string | Parent epic ID (if part of an epic) |
epicTitle | string | Parent epic title |
Context Information
| Variable | Type | Description |
|---|---|---|
trackerName | string | Active tracker: "json", "beads", "beads-bv" |
agentName | string | Active agent: "claude", "opencode" |
model | string | Model being used (if configured) |
cwd | string | Current working directory path |
currentDate | string | Current date in ISO format (YYYY-MM-DD) |
currentTimestamp | string | Current timestamp in ISO format |
beadsDbPath | string | Full path to beads database (for bd --db flag) |
PRD Context (Project Requirements)
When using a tracker that supports PRD context (JSON tracker with metadata.sourcePrd), these variables provide full project visibility:
| Variable | Type | Description |
|---|---|---|
prdName | string | Name of the PRD/project |
prdDescription | string | PRD description |
prdContent | string | Full PRD markdown content (for agent to study) |
prdCompletedCount | string | Number of completed tasks/stories |
prdTotalCount | string | Total number of tasks/stories |
Progress & Patterns
| Variable | Type | Description |
|---|---|---|
recentProgress | string | Summary of progress from recent iterations |
codebasePatterns | string | Learnings and patterns from previous iterations |
selectionReason | string | Why this task was selected (beads-bv tracker) |
Variable Details
taskDescription
The full description from your task tracker. For JSON (prd.json), this is the story description. For Beads, it's the issue body.
acceptanceCriteria
Extracted from task metadata or parsed from description. Ralph formats array-based criteria as a markdown checklist:
Renders as:
dependsOn and blocks
These show task relationships for dependency-aware workflows:
recentProgress
When cross-iteration progress tracking is enabled, this contains a summary of recent work:
The progress file is managed automatically by Ralph and includes:
- Notes from previous iterations
- Insights and learnings
- Context for the current task
PRD Context Variables
When your tracker provides PRD context (e.g., JSON tracker with metadata.sourcePrd), you can include full project context in your prompts:
This gives the AI agent full visibility into the project requirements and current progress.
codebasePatterns
Contains learnings and patterns discovered during previous iterations:
Patterns are typically extracted from .ralph-tui/progress.md and help agents avoid repeating mistakes.
selectionReason (beads-bv)
For the beads-bv tracker with graph-aware selection, this explains why the current task was chosen:
This might include information about dependencies, blocking relationships, or priority scores.
priority
Priority as a string, where lower numbers = higher priority:
| Value | Meaning |
|---|---|
| "0" | Critical/P0 |
| "1" | High/P1 |
| "2" | Medium/P2 (default) |
| "3" | Low/P3 |
| "4" | Backlog/P4 |
Advanced Usage
Accessing Raw Objects
For advanced templates, access the full task and config objects:
Raw object access exposes internal structure that may change. Use documented variables when possible for forward compatibility.
Iterating Over Arrays
When accessing raw arrays (like from task.labels):
Nested Conditionals
Combine conditions for complex logic:
Handlebars Syntax Reference
Expression Escaping
By default, Handlebars escapes HTML entities. Ralph disables this (using noEscape: true), so your content renders as-is:
Block Helpers
| Helper | Usage | Description |
|---|---|---|
if | \{\{#if var\}\}...\{\{/if\}\} | Renders block if truthy |
unless | \{\{#unless var\}\}...\{\{/unless\}\} | Renders block if falsy |
each | \{\{#each array\}\}...\{\{/each\}\} | Iterates over array |
with | \{\{#with object\}\}...\{\{/with\}\} | Changes context |
Special Variables
| Variable | Context | Description |
|---|---|---|
this | Inside each | Current array item |
@index | Inside each | Current index (0-based) |
@first | Inside each | True if first iteration |
@last | Inside each | True if last iteration |
@key | Inside each (object) | Current property key |
Path Notation
Access nested properties with dot notation:
Common Patterns
Fallback Values
Show a default when variable is empty:
Conditional Sections
Include entire sections conditionally:
Formatted Lists
When you have comma-separated values:
Note: labels is already comma-joined by Ralph. For full control, access task.labels array directly.
Date/Time Context
Include temporal context:
Troubleshooting
Variable Not Rendering
If a variable shows as empty:
- Check the variable name spelling
- Verify your tracker provides that data
- Use
ralph-tui template showto see available data
Syntax Errors
Common mistakes:
Conditional Not Working
Handlebars considers these falsy:
- Empty string
"" nullorundefinedfalse0- Empty array
[]
If your variable is an empty string, the \{\{#if\}\} block won't render.
Template Examples by Use Case
Strict Quality Gates
Minimal Context
Maximum Context
Next Steps
- Template Customization - Create your own templates
- Configuration - Set template paths and options