Templates

This documentation is incomplete.

Tomahawk uses Symfony's PhpEngine and Twig for templates. A Delegating engine is used so you can use either or both the template engines mentioned.

The easiest way to use the Template component is to make sure your Controllers extend Tomahawk\Routing\Controller. You then have access to it through $this->templating.

Otherwise just add the following parameter to the construct method of your Controller Symfony\Component\Templating\EngineInterface and it will get injected in through the Service Container.

Template files must be in the Resources/views folder with you Bundle.

For more information on the PhpEngine please refer to the docs here. For more information on Twig please refer to the docs here.

Rendering A Template

A template name has the format 'Bundle:Section:view.engine' The engine can be omitted and defaults to .php.

Rendering Using Full Template Name

Below is an example of rendering a template using the full name:

Rendering Using Partial Template Name

You can omit the Section if the template is in the view root page:

Passing Parameters To The Template

You can pass parameters to the template file by passing an array as the second parameter to render.