place grid sections macro to another file
This commit is contained in:
parent
354a0a958a
commit
7aea4d4db8
40
template/grid_sections.html.njk
Normal file
40
template/grid_sections.html.njk
Normal file
|
@ -0,0 +1,40 @@
|
|||
{% macro render_item(item) %}
|
||||
|
||||
{% set class_str = "item" %}
|
||||
{% if item.highlight %}
|
||||
{% set class_str = class_str + " " + "highlight" %}
|
||||
{% endif %}
|
||||
|
||||
{% set href = "/#" %}
|
||||
{% if item.permalink is defined and not item.hide_permalink %}
|
||||
{% set href = item.permalink %}
|
||||
{% endif %}
|
||||
|
||||
{% set misc_attr = "" %}
|
||||
{% if item.hide_permalink %}
|
||||
{% set misc_attr = misc_attr + " " + "hidden_permalink=\"" + item.permalink + "\"" %}
|
||||
{% set misc_attr = misc_attr + " " + "seed=\"" + item.seed + "\"" %}
|
||||
{% endif %}
|
||||
|
||||
<a class="{{ class_str }}" href="{{ href | safe }}" {{ misc_attr | safe }}>
|
||||
<dl>
|
||||
<dt>{{ item.name }}</dt>
|
||||
{% if item.description is defined %}
|
||||
<dd>{{ item.description }}</dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
</a>
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
{% macro render_section(sect) %}
|
||||
<section>
|
||||
<h2>{{ sect.name }}</h2>
|
||||
|
||||
<div class="item_container">
|
||||
{% for item in sect.items %}
|
||||
{{ render_item(item) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endmacro %}
|
|
@ -1,45 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
{% macro render_item(item) %}
|
||||
|
||||
{% set class_str = "item" %}
|
||||
{% if item.highlight %}
|
||||
{% set class_str = class_str + " " + "highlight" %}
|
||||
{% endif %}
|
||||
|
||||
{% set href = "/#" %}
|
||||
{% if item.permalink is defined and not item.hide_permalink %}
|
||||
{% set href = item.permalink %}
|
||||
{% endif %}
|
||||
|
||||
{% set misc_attr = "" %}
|
||||
{% if item.hide_permalink %}
|
||||
{% set misc_attr = misc_attr + " " + "hidden_permalink=\"" + item.permalink + "\"" %}
|
||||
{% set misc_attr = misc_attr + " " + "seed=\"" + item.seed + "\"" %}
|
||||
{% endif %}
|
||||
|
||||
<a class="{{ class_str }}" href="{{ href | safe }}" {{ misc_attr | safe }}>
|
||||
<dl>
|
||||
<dt>{{ item.name }}</dt>
|
||||
{% if item.description is defined %}
|
||||
<dd>{{ item.description }}</dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
</a>
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
{% macro render_section(sect) %}
|
||||
<section>
|
||||
<h2>{{ sect.name }}</h2>
|
||||
|
||||
<div class="item_container">
|
||||
{% for item in sect.items %}
|
||||
{{ render_item(item) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endmacro %}
|
||||
{% import "grid_sections.html.njk" as grid_sections %}
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
@ -66,7 +27,7 @@
|
|||
</div>
|
||||
|
||||
{% for s in section %}
|
||||
{{ render_section(s) }}
|
||||
{{ grid_sections.render_section(s) }}
|
||||
{% endfor %}
|
||||
|
||||
</main>
|
||||
|
|
Loading…
Reference in a new issue