Pebble Functions
A set of utility functions registered by Invirt that can be used inside Pebble templates.
request()
Returns the current http4k Request (wrapped in an InvirtRequest).
This function is required inside macros, where the context request object
is not visible. Outside macros either form works.
{% macro requestSummary() %}
{{ request().uri }}
{{ request().method }}
{% endmacro %}
{{ request.method }}
{{ request.query("q") }}
errors()
Returns the validation errors object (io.validk.ValidationErrors), or null if there are no validation
errors for the current request. Required inside macros — outside, the
errors context object is equivalent.
Read more about validation here.
{% if errors().hasErrors("name") %}
<div class="text-error">{{ errors().error("name") }}</div>
{% endif %}
json(value)
Renders the given object as a JSON string. Typically used when embedding model data into a JavaScript context.
<div id="map" data-map-place='{{ json(model.place) | raw }}'></div>
jsonArray(value)
Same as json(), but always renders the value as a JSON array. When value is not a collection it is
wrapped in a single-element array.
<div id="map" data-map-places='{{ jsonArray(model.places) | raw }}'></div>
today()
Returns the current date as a java.time.LocalDate.
Today is {{ today() }}
uuid()
Returns a new time-ordered UUIDv7 as a hex string (no dashes). Convenient for unique DOM ids in templates.
<input type="text" id="field-{{ uuid() }}"/>
currencyFromMinorUnit(minorUnitAmount, currency)
Formats a minor-unit currency value (pence/cents) as a human-readable string using the currency's symbol and default fraction digits.
{{ currencyFromMinorUnit(order.totalMinorUnit, "GBP") }} // £12.50
pluralize(count, singular, plural)
Returns singular when count == 1 and plural otherwise.
You have {{ model.count }} {{ pluralize(model.count, "message", "messages") }}.
dateWithDaySuffix filter
Formats a java.time.Temporal (LocalDate, LocalDateTime, Instant) using a DateTimeFormatter
pattern, inserting the English ordinal suffix on the day of month (1st, 2nd, 3rd, ...).
{{ model.dispatchedAt | dateWithDaySuffix("EEEE, MMMM d yyyy") }}
{# → "Wednesday, March 1st 2026" #}