You are reading the documentation for the 1.x version. Switch to the current version 2.x.

Twig namespaces

Last updated: Fri, 29 May 2020 14:19

You can use the twig namespace to separate templates or parts of your project.

Declaration

Paths need to be declared in your configuration file like this:

{
    "twig": {
        "paths": {
            "foo": "%berlioz.directories.templates%/foo",
            "bar": "%berlioz.directories.templates%/bar"
        }
    }
}

Namespaces can be accessed by this notation:

$this->render('@foo/index.html', []);
$this->render('@bar/index.html', []);