forked from sc3/crime-punishment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros.html
58 lines (42 loc) · 1.8 KB
/
macros.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!-- {# Switching table for generating data inventory sections.
Call "{{ inventory('mystage') }}" in a markdown file,
where 'mystage' is the stage variable defined here.
The primary advantage of having this macro is to define the spreadsheet to pull from for a given stage name.
The things to pass in to this macro include the availablility type of that section, as well optionally whether you want an expandable, and how much space the expandable should take up. #} !-->
{% macro inventory(stage, availability, expand='no', size='1x') -%}
{% if stage == 'callforservice' %}
{{ expandable(stage, callforservice_fields, availability, expand, size) }}
{% endif %}
{% if stage == 'incidents' %}
{{ expandable(stage, incidents_fields, availability, expand, size) }}
{% endif %}
{% if stage == 'arrest' %}
{{ expandable(stage, arrest_fields, availability, expand, size) }}
{% endif %}
{% if stage == 'jail' %}
{{ expandable(stage, jail_fields, availability, expand, size) }}
{% endif %}
{% if stage == 'court' %}
{{ expandable(stage, court_fields, availability, expand, size) }}
{% endif %}
{% if stage == 'prison' %}
{{ expandable(stage, prison_fields, availability, expand, size) }}
{% endif %}
{%- endmacro %}
<!-- Lower level mechanism for creating expandable sections.
The reason everything is left aligned is because of how this macro is pulled into the spreadsheet. This could be fixed by fine-tuning Jinja's whitespace configuration. -->
{% macro expandable(stage, spreadsheet, availability, expand, size) -%}
<div id="{{stage}}-{{availability}}"
{% if expand == 'expand' %}
class="expandable expandable-{{size}}"
{% endif %}
>
<ul>
{% for field in spreadsheet %}
{% if field.availability == availability %}
<li>{{ field.name }}</li>
{% endif %}
{% endfor %}
</ul>
</div>
{%- endmacro %}