Bolt has some rules to help you quickly build custom templates for your site.
If your template is named exactly like the singular_slug or slug for the content
type or record it will automatically be used.

Rules for Records

The ContentType has a ‘templateselect field’ and a template is selected for this record.

The ContentType definition has a value for record_template.

Bolt will check if a template with a suited name exists, like entry.twig or page.twig

The permissions needed to perform an action are configurable by editing app/config/permissions.yml.
This can be done either directly, or through Bolt’s back-end UI. By changing the permissions you basically change the way
how people can interact with Bolt, and who is allowed to do what.

Bolt allows you to configure the routing to your needs. This basically
means that you can configure Bolt to generate and interpret URLs the way
you need them to be. There are some caveats with regards to correct
canonical URLs, but otherwise you can change it to anything you like.
The easiest way to add your own is to follow the examples defined in the
distributed routing.yml.dist file. The order of the routes is important
because it is routing is done on a first-come first-serve basis.

Use this to include another Twig template in the current template.
Twig parses the template like any other template, so you can use any
tags in your included template that you would use in the ‘main’
template. You can also use include inside the included templates."

Syntax

Meaning

{% include '_header.twig' %}

Includes the file _header.twig.

{% set v = {'title': 'Hello!'} %}{% include '_header.twig' with v %}

You can set variables to contain literals, arrays, hashes, etc.

An alternative to using 'include', is to set up your templates using Template
Inheritance. This is a method of defining a base template, and then expand it in
more detail in the templates that extend this base template. See the section on
Template inheritance on the twig website.

Functions in twig look like this: {{ foo('bar', 1, 2) }}. A
function can take zero or more parameters. Basically, a function does
something, and then returns the result for output or further processing.

Name

Function

dump(var)

Print a nicely formatted dump of the contents of var.

backtrace()

Print a formatted dump of the backtrace stack, with the "followed path" through the code.

excerpt(var, length)

Create a short excerpt from var, without HTML formatting, restricted by length characters. var can be a 'record' object, a single value from a 'record' or a regular string.*

markdown()

Parse a given string as Markdown. *

current()

Checks if a given record corresponds to the page being shown in the browser. *

htmllang

Returns the language value for in tags where the language attribute is required

Filters in twig look like this: {{ 'foo'|filter }}, and can take
optional parameters. A filter basically transforms whatever you put into
it, so it can be processed further. Filters can be chained together, for
example: {{ record.title|excerpt(20)|lower }}.

Name

Function

localedatetime(date)

Returns the date and time in a particular format. Takes the locale into account. See strftime() for fomatting options

twig(string)

Formats the given string as Twig in HTML

ucfirst(string)

Make a string's first character uppercase.

slug(string)

Return the 'sluggified' version of a string: 'Lørüm Ipsum' -> 'lorum-ipsum'

shy(string)

Add 'soft hyphens' to a string. These normally inivisble hyphens, allow a browser to wrap a string, if it wouldn't fit the layout otherwise.

safestring(string)

Return a 'safe string' version of a given string: 'Lørüm Ipsum' -> 'lorum ipsum'

order(array, key)

Order an array, based on the given 'key'.

json_decode

Leniently decode a serialized compound data structure to an array / object. Note: json_encode does the opposite, and is built-in in Twig.

If you’re coding and you want to get a quick look at whatever variable or object you’re trying to manipulate, you can dump its contents to the browser. In templates, use the following:
The variable can be a normal variable, a single record, multiple records, or other stuff.

Code

Function

{{ dump(variable) }}

Dump 'variable' in the template.

dump($variable);

Dump 'variable' in your code.

{{ backtrace() }}

Get a backtrace throught the code to the current point in the execution, in the template.

dump(debug_backtrace());

Get a backtrace throught the code to the current point in the execution, in your code. The optional parameter denotes the maximum depth of the output of the backtrace.