Skip to content

Commit

Permalink
Added ability to set slide/section "data-*" attributes (#1861)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
bouzidanas and pre-commit-ci[bot] committed Sep 12, 2022
1 parent 4c1f0c5 commit e618f91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 4 additions & 3 deletions 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) -%}
<section>
<section {{ cellslidedata(cell) }}>
{%- endif -%}
{%- if cell.metadata.get('subslide_start', False) -%}
<section>
<section {{ cellslidedata(cell) }}>
{%- endif -%}
{%- if cell.metadata.get('fragment_start', False) -%}
<div class="fragment">
<div class="fragment" {{ cellslidedata(cell) }}>
{%- endif -%}

{%- if cell.metadata.slide_type == 'notes' -%}
Expand Down
9 changes: 9 additions & 0 deletions 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 %}

0 comments on commit e618f91

Please sign in to comment.