php twig code example
Example 1: twig for
<ul>
{% for key, user in users %}
<li>{{ key }}: {{ user.username|e }}</li>
{% endfor %}
</ul>
Example 2: twig for
{% for i in 0..10 %}
* {{ i }}
{% endfor %}
Example 3: twig resto
{% if loop.index is divisible by(3) %}
Example 4: 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>