-
Notifications
You must be signed in to change notification settings - Fork 6
/
_macros.html
94 lines (73 loc) · 3.27 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{% macro build_content(content, right_rail, images) %}
{% for row in content %}
{% set rowloop = loop %}
{% if row.content_type == "text" %}
{{ build_text(row, right_rail, images) }}
{% elif row.content_type == "subhead" %}
{{ build_subhead(row) }}
{% elif row.content_type == "markup" %}
{{ build_markup(row.value) }}
{% elif row.content_type == "image" %}
{{ build_images(row, images) }}
{% endif %}
{% endfor %}
{% endmacro %}
{% macro build_text(text_row, right_rail, images) %}
<div class="row" {% if text_row.id %} id={{ text_row.id }} {% endif %}>
<div class="col-sm-7 col-sm-offset-1 col-xs-10 col-xs-offset-1">
<p>{{ text_row.value.replace("\n", "</p><p>") | replaceMarkdownLinks | safe }}</p>
</div>
{% if text_row.right_rail_id %}
<div class="col-sm-3 col-sm-offset-0 col-xs-10 col-xs-offset-1" {% if right_rail|filter('right_rail_id', text_row.right_rail_id, 'id')|first %} id="{{ right_rail|filter('right_rail_id', text_row.right_rail_id, 'id')|first }}" {% endif %}>
{{ build_right_rail(right_rail|filter('right_rail_id', text_row.right_rail_id)|first, images) }}
</div>
{% endif %}
</div>
{% endmacro %}
{% macro build_right_rail(right_rail_row, images) %}
{% if right_rail_row.content_type == "text" %}
<p>{{ right_rail_row.value | safe}}</p>
{% elif right_rail_row.content_type == "markup" %}
{{ build_markup(right_rail_row.value) }}
{% elif right_rail_row.content_type == "image" %}
{{ load_images(right_rail_row, images) }}
{% endif %}
{% endmacro %}
{% macro build_subhead(subhead_row) %}
<div class="row" {% if subhead_row.id %} id={{ subhead_row.id }} {% endif %}>
<div class="col-sm-7 col-sm-offset-1 col-xs-10 col-xs-offset-1">
<h2>{{ subhead_row.value }}</h2>
</div>
</div>
{% endmacro %}
{% macro build_markup(markup) %}
{% if markup | regex_match("^_.+\.html$") %} {# if markup references a .html file, then pull markup from there #}
{% include markup %}
{% else %}
{{ markup | safe }} {# otherwise, load markup directly in from the file #}
{% endif %}
{% endmacro %}
{% macro build_images(image_row, images) %}
<div class="row">
<div class="col-xs-10 col-xs-offset-1">
{{ load_images(image_row, images) }}
</div>
</div>
{% endmacro %}
{% macro load_images(image_row, images) %}
{% for image in images|filter('image_group', image_row.value) %}
{% if image.image_layout == "full" or image.image_layout == "half left" or image.image_layout == "half right" or image.image_layout == "third left" or image.image_layout == "third middle" or image.image_layout == "third right" %}
<div class="full-image {{ image.image_layout }}" id="{{ image.image_id }}">
<img class="ajmint-unveil" src="img/icons/loading.png" data-src="{{ image.image_source }}" />
<noscript>
<img src="{{ image.image_source }}" />
</noscript>
</div>
{% else %}
<p class="tarbell-error">ERROR WITH IMAGE LAYOUT</p>
{% endif %}
{% endfor %}
{% if images|filter('image_group', image_row.value, 'caption')|first %}
<div class="caption">{{ images|filter('image_group', image_row.value, 'caption') |first | replaceMarkdownLinks | safe }}</div>
{% endif %}
{% endmacro %}