twig symfony code example
Example 1: twig symfony get route
{% set current_path = app.request.get('_route') %}
{{ current_path }}
Example 2: symfony twig source
{
{{ source('path/to/template.html.twig') }}
Example 3: controller to render static data symfony
{
{
<div id="sidebar">
{
{{ render(path('latest_articles', {max: 3})) }}
{{ render(url('latest_articles', {max: 3})) }}
{
use the controller() function to define the controller to execute
{{ render(controller(
'App\\Controller\\BlogController::recentArticles', {max: 3}
)) }}
</div>