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'}} |
| Named parameters | {{helper arg name=value}} |
| 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), object (builds an object from named parameters) |
| Date | now, date, dateAdd, dateSub, dateIso, dateTimestamp, dateDiff |
| Control | with, typeof, return (halt and return what rendered so far) |
Named parameters
Helpers accept name=value pairs after all positional arguments. Values can be literals, context paths, variables, or parenthesized expressions. Helpers that do not use a named parameter silently ignore it. The object helper builds an object from its named parameters, which is how you construct object values inline:
{{json (object id=(uuid) status='PENDING' item=request.body)}}- Named parameters always come last: a positional argument after a named one is a parse error.
- No spaces around
=, and names must be unique within a call. objectrejects positional arguments. Its result renders as[object Object]if printed directly; wrap it injsonto render it, or pass it where a value is expected, like flag values.
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 same applies to every helper name: a payload field calledobject(common in payment APIs) is read with{{$this.object}}.