You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.1 KiB
71 lines
2.1 KiB
{% macro typeof(thing) %} |
|
{% if thing is iterable %} |
|
{% if thing is object %} |
|
dict |
|
{% else %} |
|
list |
|
{% endif %} |
|
{% else %} |
|
{% if thing is string %} |
|
str |
|
{% elif thing is number %} |
|
num |
|
{% else %} |
|
other |
|
{% endif %} |
|
{% endif %} |
|
{% endmacro typeof %} |
|
|
|
{% macro debug(thing, label="", recurse=0) %} |
|
|
|
{% set type = self::typeof(thing=thing) | trim %} |
|
|
|
<span>{% if label %}{{ label }}: {% endif %}<em>{{ type }}</em></span> |
|
|
|
{% set rdepth = recurse - 1 %} |
|
<div class="debug"> |
|
{% if type == "dict" %} |
|
{% for k, v in thing %} |
|
{% if v is iterable and recurse %} |
|
<span>{{ k }}: {{ self::debug(thing=v, recurse=rdepth) }}</span> |
|
{% else %} |
|
<span>{{ k }}: {{ v }}</span><br> |
|
{% endif %} |
|
{% endfor %} |
|
{% elif type == "list" %} |
|
{% for v in thing %} |
|
{% if v is iterable and recurse %} |
|
<span>{{ self::debug(thing=v, recurse=rdepth) }}</span> |
|
{% else %} |
|
<span>{{ v }}</span><br> |
|
{% endif %} |
|
{% endfor %} |
|
{% else %} |
|
{{ thing }} |
|
{% endif %} |
|
</div> |
|
{% endmacro debug %} |
|
|
|
{% macro parent_tree(ancestors) %} |
|
<div class="sections"> |
|
{% for sect in ancestors %} |
|
{% set sect = get_section(path=sect) %} |
|
<span style="padding-left: {{ loop.index0 }}em;"> |
|
<a href="{{ sect.permalink }}" class="stealth"> |
|
{{ sect.title }}/ |
|
</a> |
|
</span> |
|
{% endfor %} |
|
</div> |
|
{% endmacro section_tree %} |
|
|
|
{% macro subsection_tree(subs) %} |
|
<ul> |
|
{% for sub in subs %} |
|
{% set sub = get_section(path=sub) %} |
|
<li><a href="{{ sub.permalink }}" class="stealth"> |
|
{{ sub.title }} |
|
</a></li> |
|
{% endfor %} |
|
</ul> |
|
{% endmacro subsection_tree %} |