Extensions provide a convenient way of turning custom PHP code into statements of the template language. Besides the fact that extensions are always called by their full name including their namespace, the syntax is the same as for regular functions and filters.
<# Generic extension. #>
<@ Vendor/Extension { options } @>
<# Custom filter. #>
@{ variable | Vendor/Filter }
Installing Extensions
Extensions are distributed as packages and can be installed using the package manager in the dashboard. Packages that are not published can also simply be copied into the packages directory of your installation. After installation, an extension is available in all templates of all themes.
Generic Extensions
Generic extensions are used like functions. Options are passed as a relaxed JSON object and can contain variables and filters. Whatever is returned by the extension is rendered in place of the statement.
<@ Vendor/Gallery {
glob: @{ galleryFiles | def ('*.jpg') },
width: 400,
class: 'gallery'
} @>
Custom Filters
Custom filters are used like any built-in filter and can also be chained with other filters. Parameters are passed in parentheses.
@{ title | Vendor/Slugify | strtoupper }
@{ text | Vendor/Truncate (100, '...') }
Precedence
When a statement is called, Automad first looks for a matching snippet, built-in function or custom function before trying to load an extension. Since extension names always contain a namespace, conflicts with other statements are practically impossible.