Skip to content

Search tags, filters, functions and guides.

Language / Strict mode

Language

Strict mode

How Kiln catches typos and missing data.

Strict mode is on by default. It turns a misspelt variable or a missing property into an error, instead of a blank space on the page that nobody notices.

page.kiln
<h1>{{ titel }}</h1>
Error
Unknown variable "titel" in page.kiln at line 1, column 8. Did you mean "title"?

Optional data

When data may be missing, say so in the template. These never raise missing-variable or missing-property errors:

  • ?. returns null if the left side is null: page?.author?.name
  • ?? uses a fallback: page.subtitle ?? ""
  • default uses a fallback when the value is empty: page.subtitle|default("")
  • is defined checks whether a value exists: {% if page.subtitle is defined %}
page.kiln
<h1>{{ page.title }}</h1>
<p>{{ page.subtitle ?? "No subtitle" }}</p>
Output
<h1>About</h1>
<p>No subtitle</p>

Strict and lenient

SituationStrictLenient
Unknown variableErrornull
Missing propertyErrornull
Property of nullErrornull
Required prop missingErrornull
Prop not declaredErrorIgnored
Prop of the wrong typeErrorNot checked
Unknown filter, function, test or tagErrorError
Type errors, such as "a" + 1ErrorError

Turning it off

Lenient mode treats missing data as null. Turn it on for the whole environment:

const kiln = createKiln({ loader, strict: false });

We recommend leaving strict mode on. Guarding optional data takes a few characters and catches real bugs.