templates/blog/post_show.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block body_id 'blog_post_show' %}
  3. {% block main %}
  4.     <h1>{{ post.title }}</h1>
  5.     <p class="post-metadata">
  6.         <span class="metadata"><i class="fa fa-calendar"></i> {{ post.publishedAt|format_datetime('long', 'medium', '', 'UTC') }}</span>
  7.         <span class="metadata"><i class="fa fa-user"></i> {{ post.author.fullName }}</span>
  8.     </p>
  9.     {{ post.content|markdown_to_html|sanitize_html }}
  10.     {{ include('blog/_post_tags.html.twig') }}
  11.     <div id="post-add-comment" class="well">
  12.         {# The 'IS_AUTHENTICATED_FULLY' role ensures that the user has entered
  13.         their credentials (login + password) during this session. If they
  14.         are automatically logged via the 'Remember Me' functionality, they won't
  15.         be able to add a comment.
  16.         See https://symfony.com/doc/current/security/remember_me.html#forcing-the-user-to-re-authenticate-before-accessing-certain-resources
  17.         #}
  18.         {% if is_granted('IS_AUTHENTICATED_FULLY') %}
  19.             {{ render(controller('App\\Controller\\BlogController::commentForm', {'id': post.id})) }}
  20.         {% else %}
  21.             <p>
  22.                 <a class="btn btn-success" href="{{ path('security_login', {'redirect_to': app.request.pathInfo}) }}">
  23.                     <i class="fa fa-sign-in" aria-hidden="true"></i> {{ 'action.sign_in'|trans }}
  24.                 </a>
  25.                 {{ 'post.to_publish_a_comment'|trans }}
  26.             </p>
  27.         {% endif %}
  28.     </div>
  29.     <h3>
  30.         <i class="fa fa-comments" aria-hidden="true"></i> {{ 'post.num_comments'|trans({ 'count': post.comments|length }) }}
  31.     </h3>
  32.     {% for comment in post.comments %}
  33.         <div class="row post-comment">
  34.             <a name="comment_{{ comment.id }}"></a>
  35.             <h4 class="col-sm-3">
  36.                 <strong>{{ comment.author.fullName }}</strong> {{ 'post.commented_on'|trans }}
  37.                 {# it's not mandatory to set the timezone in localizeddate(). This is done to
  38.                    avoid errors when the 'intl' PHP extension is not available and the application
  39.                    is forced to use the limited "intl polyfill", which only supports UTC and GMT #}
  40.                 <strong>{{ comment.publishedAt|format_datetime('medium', 'short', '', 'UTC') }}</strong>
  41.             </h4>
  42.             <div class="col-sm-9">
  43.                 {{ comment.content|markdown_to_html|sanitize_html }}
  44.             </div>
  45.         </div>
  46.     {% else %}
  47.         <div class="post-comment">
  48.             <p>{{ 'post.no_comments'|trans }}</p>
  49.         </div>
  50.     {% endfor %}
  51. {% endblock %}
  52. {% block sidebar %}
  53.     {% if is_granted('edit', post) %}
  54.         <div class="section">
  55.             <a class="btn btn-lg btn-block btn-success" href="{{ path('admin_post_edit', {id: post.id}) }}">
  56.                 <i class="fa fa-edit" aria-hidden="true"></i> {{ 'action.edit_post'|trans }}
  57.             </a>
  58.         </div>
  59.     {% endif %}
  60.     {# the parent() function includes the contents defined by the parent template
  61.       ('base.html.twig') for this block ('sidebar'). This is a very convenient way
  62.       to share common contents in different templates #}
  63.     {{ parent() }}
  64.     {{ show_source_code(_self) }}
  65.     {{ include('blog/_rss.html.twig') }}
  66. {% endblock %}