phpDocumentor

Using twig

phpDocumentor provides the Twig 2.x engine as a rendering engine for templates.

Configuration

The Twig engine can be configured in your template's template.xml through the tag.

<template>
    <parameters>
        <parameter key="config-key">config-value</parameter>
    </parameters>
</template>

Caching

phpDocumentor enables Twig's compilation cache by default. When developing Twig templates, you need to turn this off in your template.xml by enabling debug mode:

<parameter key="twig-debug">true</parameter>

This will also make the Twig debug extension available, which provides the dump() function.

Global Variables

The Twig writer provides two primary variables for use in your templates:

Parameters are also available as twig variables, this allows you to add static values from your configuration files in the rendered output. {{ parameter.param-key }} will give you the value of the parameter param-key

Functions

path

{{ path(relative_path) }}
relative_path
type: string

Returns the URL for the given path, relative to the current path.

Filters

markdown

{{ text|markdown }}
text
type: string

Renders Markdown text into HTML, using the Parsedown engine.

trans

{{ message|trans(context = []) }}
message
context(optional)
type: stringtype: arraydefault: []

Renders the translation of the content. Variables in context are expanded into the translated text using vsprintf.

route

{{ node|route(presentation = 'normal') }}
node
presentation(optional)
type: phpDocumentor\Descriptor\DescriptorAbstracttype: stringdefault: normal

Renders a link to the generated page for the node. presentation can be set to 'url' to render only the URL.

sortasc

{{ list|sort_asc }}
list
type: array

Sorts the given list in ascending order by name, case-insensitively. Uses the name of each node in the collection to sort. Typically used for sorting a phpDocumentor\Descriptor\Collection of descriptors.

sortdesc

{{ list|sort_desc }}
list
type: array

Sorts the given list in descending order by name, case-insensitively. Uses the name of each node in the collection to sort. Typically used for sorting a phpDocumentor\Descriptor\Collection of descriptors.

Search results