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

ConstructSyntax
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}}
  • forEach provides {item, index, total, isFirst, isLast}; each makes each element the context and provides none of those. In mock bodies producing JSON arrays, prefer forEach.
  • 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.

CategoryHelpers
Comparisonis (loose ==, coerces strings to numbers), eq (strict ===), gt, gte, lt, lte, and, or, not, default, if, unless
Stringappend, uppercase, lowercase, capitalize, startsWith, endsWith, replace, trim, split, json, uuid
Mathadd, subtract, multiply, divide, modulo, toInt, toFixed, round, random (inclusive on both ends)
ArrayforEach, each, length, itemAt (the only index access; no arr[0]), first, last, slice, includes, join, pluck, sort, unique
Objectpick (string-key access; also the only way to read keys containing dots, and to read fields off helper results)
Datenow, date, dateAdd, dateSub, dateIso, dateTimestamp, dateDiff
Controlwith, typeof, return (halt and return what rendered so far)

Gotchas

  • default only falls back on missing values; empty strings and 0 pass through.
  • Date helpers require ISO strings with an explicit time part: 2024-01-01T00:00:00.000Z, not 2024-01-01.
  • Dot-chaining on helper results is invalid: (itemAt arr 0).name does not parse; use {{pick (itemAt arr 0) 'name'}}.
  • {{uuid}} calls the helper; to read a context field literally named uuid, 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.