Extensions provide a convenient way of extending Automad's core functionality with custom PHP code, while still offering the clean syntax of the template language. Extensions are distributed as packages and can be used across all themes of a site. There are two types of extensions: generic extensions and custom pipe functions.
Generic Extensions
Generic extensions allow for developing more complex and customized template functions of any kind, having full access to all content and core features of Automad. They are used in templates like regular functions:
<@ Vendor/Extension { key: 'value' } @>
Custom Pipe Functions
In contrast to generic extensions, custom pipe functions are specifically meant to modify the value of a variable using the pipe operator. They are used in templates like any other pipe function:
@{ variable | Vendor/Name }
Comparison
| Custom Function | Generic Extension | Custom Pipe Function | |
|---|---|---|---|
| Syntax | <@ name { ... } @> | <@ Vendor/Name { ... } @> | @{ var | Vendor/Name } |
| Defined in | A theme | A separate package | A separate package |
| Input | Options and $Automad | Options and $Automad | The variable value and parameters |
| Assets | No | CSS and JS are loaded automatically | No |
| Use in other theme | No | Yes | Yes |