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.
47 lines
1.3 KiB
47 lines
1.3 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 %} |