Reference
Bigodon
Bigodon is the Handlebars-like language mock bodies are written in. This page is the syntax reference plus the built-in helpers you will actually reach for; the exhaustive helper list lives in the Bigodon repository.
Syntax
| Construct | Syntax |
|---|---|
| Path expression | {{user.name}} |
| Helper call | {{capitalize name}} |
| Nested helpers | {{default (capitalize name) 'stranger'}} |
| Comment | {{! ignored }} |
| Variable assignment | {{= $var value}} |
| Variable read | {{$var}} |
| Block | {{#expr}}...{{/expr}} |
| Negated block | {{^expr}}...{{/expr}} |
| Else | {{else}} or {{else helper args}} for chains |
| Current item / parents | $this, $parent (chainable), $root |
| Escaped braces | \{{ and \}} render literal braces |
- String literals accept single, double, or backtick quotes. Spaces inside
{{ }}are optional. - No space is allowed between
{{and#,^, or/. - There is no HTML escaping and no triple-stash:
{{value}}renders values as-is.
Blocks and context
A block over an array iterates it; a block over an object makes it the context; helpers like if and comparison blocks do not change context at all:
{{#is status 'active'}}Active{{else is status 'pending'}}Pending{{else}}Unknown{{/is}}
{{#forEach items}}
{{index}}: {{item.name}}{{^isLast}},{{/isLast}}
{{/forEach}}forEachprovides{item, index, total, isFirst, isLast};eachmakes each element the context and provides none of those. In mock bodies producing JSON arrays, preferforEach.- In chained else-if blocks, close only the outermost helper.
- Blocks work on helper calls and context paths, not variables: use
{{#if $var}}/{{#unless $var}}for variables. - Variables are global within a request: assignments inside blocks persist outside, which enables accumulator patterns.
Most-used helpers
A curated subset by category. Aliases exist for many (for example lower / downcase); the repository lists every helper and alias.
| Category | Helpers |
|---|---|
| Comparison | is (loose ==, coerces strings to numbers), eq (strict ===), gt, gte, lt, lte, and, or, not, default, if, unless |
| String | append, uppercase, lowercase, capitalize, startsWith, endsWith, replace, trim, split, json, uuid |
| Math | add, subtract, multiply, divide, modulo, toInt, toFixed, round, random (inclusive on both ends) |
| Array | forEach, each, length, itemAt (the only index access; no arr[0]), first, last, slice, includes, join, pluck, sort, unique |
| Object | pick (string-key access; also the only way to read keys containing dots, and to read fields off helper results) |
| Date | now, date, dateAdd, dateSub, dateIso, dateTimestamp, dateDiff |
| Control | with, typeof, return (halt and return what rendered so far) |
Gotchas
defaultonly falls back on missing values; empty strings and0pass through.- Date helpers require ISO strings with an explicit time part:
2024-01-01T00:00:00.000Z, not2024-01-01. - Dot-chaining on helper results is invalid:
(itemAt arr 0).namedoes not parse; use{{pick (itemAt arr 0) 'name'}}. {{uuid}}calls the helper; to read a context field literally nameduuid, write{{$this.uuid}}.
The practical, example-driven walkthrough of all of this is the Templatingpage; Mocko's own helpers (status, headers, proxy, flags) are in Template Helpers.