themen-hugo-35c3-reveal/layouts/shortcodes/slide.html
dzello db6d875a3f Don't try to add templates from section for _index.md
Causes a strange segfault otherwise
2018-07-23 01:36:26 +02:00

48 lines
No EOL
1.8 KiB
HTML

{{- $scratch := .Scratch -}}
{{- $scratch.Set "slides" slice -}}
{{- if len .Inner -}}
{{- $scratch.Add "slides" .Inner -}}
{{- end -}}
{{- $content := .Get "content" -}}
{{- if $content -}}
{{- $lookup := split $content "." }}
{{- $html := index .Page.Site.Data (index $lookup 0) (index $lookup 1) | markdownify -}}
{{- $slides := split $html "<hr />" -}}
{{- range $slides -}}
{{- $scratch.Add "slides" . -}}
{{- end -}}
{{- end -}}
{{- $params := . -}}
{{- $noPrefix := slice "id" "class" -}}
{{- $noOutput := slice "content" "template" -}}
{{- range $scratch.Get "slides" }}
<section data-noprocess data-shortcode-slide
{{- $template := $params.Get "template" -}}
{{- if $template -}}
{{- $scratch.Add "templateParams" (slice $.Site.Params.reveal_hugo.templates) -}}
{{- if ne $.Page.File.LogicalName "_index.md" -}}
{{- $scratch.Add "templateParams" (slice ($.Site.GetPage $.Page.Section).Params.reveal_hugo.templates) -}}
{{- end -}}
{{- $scratch.Add "templateParams" (slice $.Page.Params.reveal_hugo.templates) -}}
{{- range ($scratch.Get "templateParams") -}}
{{- if (ne . nil) -}}
{{- range $key, $value := (index . $template) -}}
{{- $scratch.SetInMap "template" $key $value | safeHTMLAttr -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- range $key, $value := ($scratch.Get "template") }}
{{- $attrName := cond (in $noPrefix $key) $key (delimit (slice "data" $key) "-") }}
{{ $attrName | safeHTMLAttr }}="{{ $value }}"
{{- end }}
data-template="{{ $template }}"
{{- end -}}
{{- range $key, $value := $.Params -}}
{{- if not (in $noOutput $key) -}}
{{- $attrName := cond (in $noPrefix $key) $key (delimit (slice "data" $key) "-") }}
{{ $attrName | safeHTMLAttr }}="{{ $value }}"
{{- end -}}
{{- end -}}>
{{ . | safeHTML }}
</section>
{{- end -}}