Skip to content

Pardon Template Patterns

In Pardon templates, interpolated patterns are substrings beginning with {{ and ending with }}. Patterns which are entirely one "{{...}}" can represent any javascript scalar value: strings, booleans, numbers, null. (If they’re not simple then they can only represent strings, of course).

A pattern is composed of the following parts, and all of them are optional (spaces are also allowed around/in many of the syntax elements).

{{?scope.subscope.param=expression%/regex/}}

The param part identifies the value for use in other templates or expressions.

This names the value for use in other expressions, or gives it a name that can be parameterized by external values (input).

On top of this value-structure we also allow patterns themselves to be transformed by the current configuration.

Pattern hints

The hint part annotates the value. In addition to configuring the rendering and matching engine, it can be used to configure the regular expression that the pattern expand to. This can be contextual, for instance, in URLs, https://example.com/items/{{item}} would match https://example.com/items/abc but not https://example.com/items/abc/color.

If you need to match a path with multiple parts, use the hint ...: E.g., https://example.com/blog/{{...post}} would match https://example.com/blog/path/to/my/post.