Skip to content

Commit fa96050

Browse files
committed
Code duplications removed and memory usage improved
Signed-off-by: Matt Friedman <[email protected]>
1 parent 68ac950 commit fa96050

4 files changed

+46
-55
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% if top_five_topic.TOPIC_PREVIEW_FIRST_POST %}
2-
{% set preview = top_five_topic %}
3-
{% include '@vse_topicpreview/topicpreview.html' %}
4-
{% endif %}
1+
{% import '@vse_topicpreview/topicpreview_macro.html' as macro %}
2+
3+
{# Display topic preview in Top Five extension #}
4+
{{ macro.renderTopicPreview(top_five_topic) }}
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
1+
{% import '@vse_topicpreview/topicpreview_macro.html' as macro %}
2+
13
{# display topic preview in view forum #}
2-
{% if topicrow.TOPIC_PREVIEW_FIRST_POST %}
3-
{% set preview = topicrow %}
4-
{% include '@vse_topicpreview/topicpreview.html' %}
5-
{% endif %}
4+
{{ macro.renderTopicPreview(topicrow) }}
65

76
{# display topic preview in search results #}
8-
{% if searchresults.TOPIC_PREVIEW_FIRST_POST %}
9-
{% set preview = searchresults %}
10-
{% include '@vse_topicpreview/topicpreview.html' %}
11-
{% endif %}
7+
{{ macro.renderTopicPreview(searchresults) }}
128

139
{# display topic preview in Similar Topics extension #}
14-
{% if similar.TOPIC_PREVIEW_FIRST_POST %}
15-
{% set preview = similar %}
16-
{% include '@vse_topicpreview/topicpreview.html' %}
17-
{% endif %}
10+
{{ macro.renderTopicPreview(similar) }}
1811

1912
{# display topic preview in Recent Topics extension #}
20-
{% if recent_topics.TOPIC_PREVIEW_FIRST_POST %}
21-
{% set preview = recent_topics %}
22-
{% include '@vse_topicpreview/topicpreview.html' %}
23-
{% endif %}
13+
{{ macro.renderTopicPreview(recent_topics) }}
2414

2515
{# DEPRECTATED: @v2.2.1 display topic preview in Top Five extension #}
26-
{% if top_five_topic.TOPIC_PREVIEW_FIRST_POST %}
27-
{% set preview = top_five_topic %}
28-
{% include '@vse_topicpreview/topicpreview.html' %}
29-
{% endif %}
16+
{{ macro.renderTopicPreview(top_five_topic) }}

styles/all/template/topicpreview.html

-31
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{% macro renderTopicPreview(context) %}
2+
{% if context.TOPIC_PREVIEW_FIRST_POST %}
3+
<div class="topic_preview_content" style="display: none;">
4+
{% if context.TOPIC_PREVIEW_LAST_POST %}
5+
<strong>{{ lang('FIRST_POST') }}</strong>
6+
<hr>
7+
{% endif %}
8+
{% if context.TOPIC_PREVIEW_FIRST_AVATAR %}
9+
<div class="topic_preview_avatar">
10+
{%- if context.TOPIC_PREVIEW_FIRST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
11+
{{ context.TOPIC_PREVIEW_FIRST_AVATAR }}
12+
{%- else -%}
13+
<div class="topic_preview_no_avatar"></div>
14+
{%- endif -%}
15+
</div>
16+
{% endif %}
17+
<div class="topic_preview_first">{{ context.TOPIC_PREVIEW_FIRST_POST }}</div>
18+
{% if context.TOPIC_PREVIEW_LAST_POST %}
19+
<div class="topic_preview_break"></div>
20+
<strong>{{ lang('LAST_POST') }}</strong>
21+
<hr>
22+
{% if context.TOPIC_PREVIEW_LAST_AVATAR %}
23+
<div class="topic_preview_avatar">
24+
{%- if context.TOPIC_PREVIEW_LAST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
25+
{{ context.TOPIC_PREVIEW_LAST_AVATAR }}
26+
{%- else -%}
27+
<div class="topic_preview_no_avatar"></div>
28+
{%- endif -%}
29+
</div>
30+
{% endif %}
31+
<div class="topic_preview_last">{{ context.TOPIC_PREVIEW_LAST_POST }}</div>
32+
{% endif %}
33+
</div>
34+
{% endif %}
35+
{% endmacro %}

0 commit comments

Comments
 (0)