Download the PHP package jaem3l/template-bundle without Composer
On this page you can find all versions of the php package jaem3l/template-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jaem3l/template-bundle
More information about jaem3l/template-bundle
Files in jaem3l/template-bundle
Package template-bundle
Short Description Provides an easy way to use twig templates in your controller.
License MIT
Informations about the package template-bundle
jaem3l TemplateBundle for Symfony 4
This bundle provides a single @Template annotation that can be used in favor of
SensioFrameworkExtraBundle's annotation with the same name.
How it works
You can see the DummyController inside tests/Annotation/TemplateTest.php as a reference. Twig is fully supported, which should make writing your templates easier.
Requirements
- PHP 7.1
- SensioFrameworkExtraBundle 5.1
- Twig 2.4
Installation
The bundle can be installed via Composer:
composer require jaem3l/template-bundle
When using this bundle inside a Symfony 4 application bootstrapped with Flex,
make sure you have installed the twig-bundle and set it up with its recipe, e.g.
by using composer req twig.
Usage examples for Route-annotation
<?php
namespace App\Controller;
use jæm3l\TemplateBundle\Annotation\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class HelloController
{
/**
* @Route("/hello1")
* @Template("Hello World")
*/
public function simpleHelloAction()
{
}
/**
* @Route("/hello2 ")
* @Template("Hello {{ name }}")
*/
public function advancedHelloAction()
{
return [
'name' => 'Santa Claus',
];
}
/**
* @Route("/twig")
* @Template("{{ 1 + 2 }}")
*/
public function simpleExpressionAction()
{
}
/**
* @Route("/advanced_hello ")
* @Template("
* {% extends 'base.html.twig' %}
*
* {% block body %}
* Hello {{ name }}!
* {% endblock %}
* ")
*/
public function advancedTemplateAction()
{
return [
'name' => 'Santa Claus',
];
}
}
Usage examples for TemplateController
In your routing you can now rely on this controller for directly rendering a provided template:
