Browse Source

Change comments code to use polymorphism via Jinja Macro

Update #63
Talha Mansoor 11 years ago
parent
commit
7083eea94c
2 changed files with 7 additions and 4 deletions
  1. 3 2
      templates/article.html
  2. 4 2
      templates/comments.html

+ 3 - 2
templates/article.html

@@ -33,12 +33,13 @@
         </nav>
     </div>
     <div class="span8 article-content">
-        {% else %}
+       {% else %}
         <div class="span8 offset2 article-content">
             {% endif %}
 
             {{ article.content }}
-            {% include 'comments.html' %}
+            {% from 'comments.html' import comments with context %}
+            {{ comments(article) }}
             <aside>
             <hr/>
             {% for an_article in dates %}

+ 4 - 2
templates/comments.html

@@ -1,4 +1,5 @@
-{% if DISQUS_SITENAME and SITEURL and article.status != 'draft' %}
+{% macro comments(article) %}
+    {% if DISQUS_SITENAME and SITEURL and article.status != 'draft' %}
 <section>
 {% if article.comments_intro %}
 <p id="comment-message">{{ article.comments_intro }} </p>
@@ -26,4 +27,5 @@
     </div>
 </div>
 </section>
-{% endif %}
+    {% endif %}
+{% endmacro %}