-
Notifications
You must be signed in to change notification settings - Fork 61
/
page.html
35 lines (32 loc) · 937 Bytes
/
page.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{% extends "layout.html" %}
{# emit a * for every slash so they can be counted #}
{%- macro countslashes(str) %}
{%- set slashcount = 0 %}
{%- for char in str %}
{%- if char == '/' -%}
*
{%- endif %}
{%- endfor -%}
{%- endmacro %}
{%- set slashcount = countslashes(pagename)|length %}
{%- macro examplename(str) %}
{%- set slashcount = 0 %}
{%- for char in str %}
{%- if char == '/' -%}
{%- set slashcount = slashcount + 1 %}
{%- else %}
{%- if slashcount > 2 and slashcount < 4 %}{{ char }}{%- endif %}
{%- endif %}
{%- endfor -%}
{%- endmacro %}
{%- set archivename = examplename(pagename)%}
{% block body %}
{%- if slashcount == 4 %}
<p>
<a href="{{ meta.get("name") ~ ".zip" }}">
<i class="fas fa-download"></i> <span class="hidden-sm hidden-tablet"> {{ _('Download this example') }}</span>
</a>
</p>
{%- endif %}
{{ body }}
{% endblock %}