-
Notifications
You must be signed in to change notification settings - Fork 0
Templates
Erika Heidi edited this page Jan 11, 2024
·
1 revision
Autodocs uses minicli/stencil, a simple template library that allows you to insert content into placeholders previously defined in a template file.
A simple markdown template file could look like this:
## {{ title }}
{{ about }}
## My Projects
{{ projects_list }}
Templates should be stored in the path defined by templates
in the Autodocs config, and they must have the .tpl
extension.
The Autodocs service provides access to a Stencil service that knows where to find your templates and will render them for you. A typical usage calls stencil->applyTemplate
from a Page's getContent
method, like the following:
public function getContent(): string
{
return $this->autodocs->stencil->applyTemplate('readme', [
'title' => $this->title,
'about' => $this->about,
'projects_list' => $this->getProjects(),
]);
}
In this example, it is assumed there is a template file named readme.tpl
in your templates folder. Notice we don't use the extension when referring to templates.