mirror of
https://github.com/torproject/community.git
synced 2024-11-23 18:00:02 +00:00
d67589fc90
Context: #251 and !219 Title slides are rendered in the slideshow template, not the slide flowblock
21 lines
907 B
Django/Jinja
21 lines
907 B
Django/Jinja
{# lektor-i18n-plugin has an edgecase where flowblock markdown isn't properly
|
|
translated <https://gitlab.torproject.org/tpo/web/community/-/issues/251#note_2819508>.
|
|
any markdown fields in a flowblock need to have a type of `text` and be
|
|
rendered with this macro, or they won't be translated.
|
|
|
|
this macro splits by line, translates all non-whitespace lines, and rejoins.
|
|
the `lines.append(...)` method returns `None` so we have to add `or ''` to
|
|
avoid rendering the literal text "None" on the page. #}
|
|
{# HACK: this is an awful hack and needs to be patched in lektor-i18n-plugin #}
|
|
{%- macro render_markdown(md_str) %}
|
|
{%- set lines = [] %}
|
|
{%- for line in md_str.split('\n') %}
|
|
{%- if line.strip() != '' %}
|
|
{{- lines.append(_(line)) or '' }}
|
|
{%- else %}
|
|
{{- lines.append(line) or '' }}
|
|
{%- endif %}
|
|
{%- endfor %}
|
|
{{- md(lines|join('\n')) }}
|
|
{% endmacro %}
|