-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmacros.html
60 lines (44 loc) · 1.61 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
59
<!-- {# Switching table for generating data inventory sections.
Call "{{ inventory('mystage', 'theavailability') }}" 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 second
thing to pass in to this macro besides the name of the stage
is the availablility type of that section. #} !-->
{% macro inventory(stage, availability) -%}
{% if stage == 'callforservice' %}
{{ expandable(callforservice_fields, stage, availability) }}
{% endif %}
{% if stage == 'incidents' %}
{{ expandable(incidents_fields, stage, availability) }}
{% endif %}
{% if stage == 'arrest' %}
{{ expandable(arrest_fields, stage, availability) }}
{% endif %}
{% if stage == 'jail' %}
{{ expandable(jail_fields, stage, availability) }}
{% endif %}
{% if stage == 'court' %}
{{ expandable(court_fields, stage, availability) }}
{% endif %}
{% if stage == 'prison' %}
{{ expandable(prison_fields, stage, availability) }}
{% endif %}
{%- endmacro %}
<!-- {# Lower level mechanism for pulling fields from a spreadsheet
by their availability.
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(spreadsheet, stage, availability) -%}
<div id="{{stage}}-{{availability}}">
<ul>
{% for field in spreadsheet %}
{% if field.availability == availability %}
<li>{{ field.name }}</li>
{% endif %}
{% endfor %}
</ul>
</div>
{%- endmacro %}