{# app/Views/Controller/test/posts.html.twig #}
{% extends "Layout/base.html.twig" %}
{% block title %}{{ action|capitalize }}{% endblock title %}
{% block head %}
{{ parent() }}
{% endblock head %}
{% block page_name %}{% if username %}{{ 'author'|trans|capitalize }}: {{ username|capitalize }}{% else %}{{ 'all_posts'|trans|title }}{% endif %}{% endblock page_name %}
{% block content %}
{% if username %}{# Get posts for this username #}
{% for post in posts %}
<div class="panel panel-default">
<div class="panel-heading">
<p class="panel-title"><strong>{{ post.title }}</strong></p>
<p class="post-date">{{ post.created|date("d.m.Y") }}</p>
</div>
<div class="panel-body">
{{ post.body }}
</div>
</div>
{% endfor %}
{% autoescape false %}
{{ paginator }}
{% endautoescape %}
{% else %}{# Get posts for all users #}
{% for user, user_posts in posts %}
<h2>{{ 'author'|trans|capitalize }}: <a href="/test/posts/{{ user }}/1">{{ user }}</a></h2>
{% for post in user_posts %}
<div class="panel panel-default">
<div class="panel-heading">
<p class="panel-title"><strong>{{ post.title }}</strong></p>
<p class="post-date">{{ post.created|date("d.m.Y") }}</p>
</div>
<div class="panel-body">
{{ post.body }}
</div>
</div>
{% endfor %}
{% endfor %}
{% endif %}
{% endblock content %}
|