Skip to main content

Pebble Context Objects

These objects are available in the root context when rendering a Pebble template via Invirt's view helpers (renderTemplate, InvirtView.ok, etc).

model

The model object passed to the renderer. Invirt uses the same naming as the http4k Pebble integration.

<input type="text" name="firstName" value="{{ model.firstName }}"/>

request

Reference to the current http4k Request (wrapped in an InvirtRequest). See Current request for the available helpers.

{{ request.method }}
{{ request.query("q") }}

errors

Validation errors (io.validk.ValidationErrors) for the current request, or null if there are none. Read more about validation here.

{% if errors.hasErrors("name") %}
<div class="text-error">{{ errors.error("name") }}</div>
{% endif %}

Context variables from InvirtPebbleConfig

Any per-request values registered via InvirtPebbleConfig.contextVariables appear here under the names supplied in the configuration map.