Runtime variables are defined by Automad during rendering. They are read-only and can't be edited in the dashboard. The names of runtime variables always start with a colon:
@{ :basename }
Runtime variables can be subdivided into three groups — variables that are related to the current context, global variables, and variables that are created by control structures.
Context Related
The following variables always refer to the page that is the current context, for example the current page in a loop.
- :basename
- The directory name of a page.
- :created
- The date and time a page was created.
- :current
- Returns
truein case a page is the currently requested page. - :currentPath
- Returns
truein case a page is part of the path to the currently requested page, like for example the parent of the current page. - :index
- The position of a page within its siblings as arranged in the dashboard. Sort by
:indexin order to use the manual order of pages. - :lastModified
- The date and time of the last modification of a page.
- :lastPublished
- The date and time a page was last published.
- :level
- The level of a page in the site tree. The homepage has level
0. - :origUrl
- The original URL of a page, in case the
urlvariable is overridden in order to redirect a page. - :parent
- The URL of the parent page.
- :path
- The file system path of a page relative to the
pagesdirectory. - :publicationState
- The publication state of a page, either
draftorpublished. - :searchResultsContext
- A short excerpt of a page's content that contains the search keywords, when a pagelist is filtered by the
searchoption. - :searchResultsCount
- The number of search hits for a page, when a pagelist is filtered by the
searchoption.
Global
- :lang
- The currently active language. In case language routing is enabled for a multilingual site, the language of the current URL is used. Otherwise the value of the
langvariable of the current page is used. The default isen. - :now
- The current date and time.
- :filelistCount
- The number of files in the currently defined filelist.
- :pagelistCount
- The number of pages in the currently defined pagelist, ignoring the limit and the pagination.
- :pagelistDisplayCount
- The number of pages in the current pagelist that are actually displayed.
- :paginationCount
- The number of pages of the pagination of the current pagelist, in case a limit is defined.
Created by Control Structures
The following variables are only available within foreach and for loops or with statements.
- :i
- The index of the current iteration. In
foreachloops, the index starts at1and continues across pages when iterating a paginated pagelist. Inforloops, the index is the current value of the counter. - :filter
- The current tag when iterating the filters of a pagelist.
- :tag
- The current tag when iterating the tags of a page.
- :file
- The path of the current file when iterating a list of files or within a
withstatement. - :basename
- The file name of the current file.
- :caption
- The caption of the current file.
- :width
- The width of the current image.
- :height
- The height of the current image.
- :fileResized
- The path of the resized version of the current image, in case a width or height is defined.
- :widthResized
- The width of the resized version of the current image.
- :heightResized
- The height of the resized version of the current image.
Custom Runtime Variables
The set function can also be used to define your own variables with a leading colon. Since such variables are never part of the page data, they don't show up as fields in the dashboard. That makes them a good choice for helper variables that are only used internally within a template.
<@ set { :teaser: @{ +main | findFirstParagraph | stripTags | 150 } } @>
<@ if @{ :teaser } @>
<p>@{ :teaser }</p>
<@ end @>