From e618f910caf3d7cece02289ff5aa04a38adf4b42 Mon Sep 17 00:00:00 2001 From: bouzidanas Date: Mon, 12 Sep 2022 08:17:29 -0500 Subject: [PATCH] Added ability to set slide/section "data-*" attributes (#1861) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- share/templates/reveal/base.html.j2 | 7 ++++--- share/templates/reveal/cellslidedata.j2 | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 share/templates/reveal/cellslidedata.j2 diff --git a/share/templates/reveal/base.html.j2 b/share/templates/reveal/base.html.j2 index 95d40011c..be07920d4 100644 --- a/share/templates/reveal/base.html.j2 +++ b/share/templates/reveal/base.html.j2 @@ -1,14 +1,15 @@ {%- extends 'lab/base.html.j2' -%} +{% from 'cellslidedata.j2' import cellslidedata %} {%- block any_cell scoped -%} {%- if cell.metadata.get('slide_start', False) -%} -
+
{%- endif -%} {%- if cell.metadata.get('subslide_start', False) -%} -
+
{%- endif -%} {%- if cell.metadata.get('fragment_start', False) -%} -
+
{%- endif -%} {%- if cell.metadata.slide_type == 'notes' -%} diff --git a/share/templates/reveal/cellslidedata.j2 b/share/templates/reveal/cellslidedata.j2 new file mode 100644 index 000000000..d759f1e92 --- /dev/null +++ b/share/templates/reveal/cellslidedata.j2 @@ -0,0 +1,9 @@ +{%- macro cellslidedata(cell) -%} + {% if cell.metadata.slideshow | length > 0 -%} + {% if cell.metadata.slideshow.data | length > 0 -%} + {% for key in (cell.metadata.slideshow.data) -%} + {{- (' data_' ~ key)|replace("_", "-") -}}="{{- cell.metadata.slideshow.data[key]|escape_html -}}" + {%- endfor -%} + {%- endif %} + {%- endif %} +{%- endmacro %}