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'}}
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}}
  • 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), object (builds an object from named parameters)
Datenow, date, dateAdd, dateSub, dateIso, dateTimestamp, dateDiff
Controlwith, 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.
  • object rejects positional arguments. Its result renders as [object Object] if printed directly; wrap it in json to render it, or pass it where a value is expected, like flag values.

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 same applies to every helper name: a payload field called object (common in payment APIs) is read with {{$this.object}}.
The practical, example-driven walkthrough of all of this is the Templatingpage; Mocko's own helpers (status, headers, proxy, flags) are in Template Helpers.