+
+` `{% for article in article\_list %}
+
+` `{% load\_article\_detail article=article isindex=True user=request.user %}
+
+` `{% empty %}
+
+` `
暂无文章
+
+` `{% endfor %}
+
+` `
+
+` `{% load\_pagination\_info page\_obj=page\_obj page\_type='index' %}
+
+
+
+{% endblock %}
+
+{% block sidebar %}
+
+` `{% load\_sidebar user=request.user linktype='article' %}
+
+{% endblock %}
+
+**模板标签执行**(blog/templatetags/blog\_tags.py)
+
+1. **load\_article\_detail 标签**:
+
+@register.inclusion\_tag('blog/tags/article\_item.html')
+
+def load\_article\_detail(article, isindex=False, user=None):
+
+` `"""渲染文章摘要卡片"""
+
+` `# 应用内容过滤钩子
+
+` `content = article.body
+
+` `if isindex:
+
+` `# 摘要模式,截断内容
+
+` `content = content[:200] + '...'
+
+` `# 触发插件Filter Hook
+
+` `content = hooks.apply\_filters('the\_content', content,
+
+` `article=article, isindex=True)
+
+` `return {
+
+` `'article': article,
+
+` `'content': content,
+
+` `'show\_full': not isindex
+
+` `}
+
+2. **load\_pagination\_info 标签**:
+
+@register.inclusion\_tag('blog/tags/pagination.html')
+
+def load\_pagination\_info(page\_obj, page\_type):
+
+` `"""生成分页HTML"""
+
+` `return {
+
+` `'page\_obj': page\_obj,
+
+` `'page\_range': page\_obj.paginator.get\_elided\_page\_range(
+
+` `page\_obj.number,
+
+` `on\_each\_side=2
+
+` `)
+
+` `}
+
+-----
+###