forked from rust-gamedev/rust-gamedev.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_figure.html
51 lines (44 loc) · 1.6 KB
/
image_figure.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
{# <!--
Displays an image with a legend.
Example usage:
{{ image_figure(
alt="image/GIF description"
src="image link"
caption="image caption") }}
Note that the caption can contain markdown:
{{ image_figure(
alt="image/GIF description"
src="image link"
caption="image caption with some **strong** text") }}
But careful! Link references don't work:
This doesn't work:
{{ image_figure(
alt="image/GIF description"
src="image link"
caption="[image caption][link]") }}
[link]: https://example.com
Use this instead:
{{ image_figure(
alt="image/GIF description"
src="image link"
caption="[image caption](https://example.com)") }}
--> #}
{% if src != "image link" %}
{# Only validate against placeholders if we're not in the example #}
{% if alt == "image/GIF description" %}
{{ throw(message="Don't forget to write your own image description :)") }}
{% endif %}
{% if caption and caption == "image caption" %}
{{ throw(message="Don't forget to write your own image caption ^^") }}
{% endif %}
{% endif %}
<figure>
{% if link %}<a href="{{link}}">{% endif %}
<img src="{{get_url(path=page.colocated_path ~ src)}}" alt="{{alt}}">
{% if link %}</a>{% endif %}
{% if caption %}
<figcaption>{{caption | markdown(inline=true) | safe}}</figcaption>
{% else %}
<figcaption>{{alt}}</figcaption>
{% endif %}
</figure>