Basic Usage / Tips & Tricks

Basic usage

You can render a Dwoo template instead of a Twig one simply by using the .dwoo extension in the template name instead of .twig.
The controller below renders the index.html.dwoo template:

src/AppBundle/Controller/DefaultController.php
<?php
public function indexAction(Request $request)
{
    return $this->render('default/index.html.dwoo');
}

Template Inheritance

Like Symfony2 PHP renderer or Twig, Dwoo provides template inheritance.

Let’s assume you have a app/Resources/views/base.html.dwoo as layout:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>{block "title"}Welcome!{/block}</title>
    {block "stylesheets"}{/block}
</head>
<body>
    {block "body"}{/block}
    {block "javascripts"}{/block}
</body>
</html>

and app/Resources/views/default/index.html.dwoo for the content:

{extends 'file:base.html.dwoo'}

{block "title"}Welcome to the DwooBundle{/block}
{block "body"}Welcome to the DwooBundle{/block}

Then the output of index.html.dwoo will be:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Welcome to the DwooBundle</title>
</head>
<body>
Welcome to the DwooBundle
</body>
</html>