Syntax Twig

Install Twig

composer require twig

Comments

{# Comment #}

Show Data

{{ mydata }}

For

{% for i in 1..100 %}
    {{ i }} <br>
{% endfor %}

For like Foreach

backend

#[Route('/blog', name: 'blog_list')]
public function list(): Response
{
return $this->render('my/exp.html.twig', array("mydata" => "Timur", "myArray" => array("test1", "test2", "test3")));
}

twig

{% for val in myArray %}
{{ val }} <br>
{% endfor %}

Include

{% include "my/header.html.twig" %}
{% include "my/header.html" %}

Links Routing

<a href="{{ path("app_lucky_number") }}">Link</a>

Assets

before need install library
composer require symfony/asset
image located in public folder
<img src="{{ asset("img/twig-logo.png") }}" alt="test">