Clean up slide shortcode

Fixes a bug outputting junk into the HTML tag as a result of Scratch calls and avoid reprocessing a section that only need to be processed once
This commit is contained in:
dzello 2018-08-07 18:27:19 +02:00
parent f6a1568da1
commit 37fcc0c158

View file

@ -14,28 +14,30 @@
{{- $params := . -}} {{- $params := . -}}
{{- $noPrefix := slice "id" "class" -}} {{- $noPrefix := slice "id" "class" -}}
{{- $noOutput := slice "content" "template" -}} {{- $noOutput := slice "content" "template" -}}
{{- range $sindex, $svalue := $scratch.Get "slides" }} {{- $template := $params.Get "template" -}}
<section data-noprocess data-shortcode-slide {{- if $template -}}
{{- $template := $params.Get "template" -}} {{- $scratch.Add "templateParams" (slice $.Site.Params.reveal_hugo.templates) -}}
{{- if $template -}} {{- if ne $.Page.File.LogicalName "_index.md" -}}
{{- $scratch.Add "templateParams" (slice $.Site.Params.reveal_hugo.templates) -}} {{- $scratch.Add "templateParams" (slice ($.Site.GetPage $.Page.Section).Params.reveal_hugo.templates) -}}
{{- if ne $.Page.File.LogicalName "_index.md" -}} {{- end -}}
{{- $scratch.Add "templateParams" (slice ($.Site.GetPage $.Page.Section).Params.reveal_hugo.templates) -}} {{- $scratch.Add "templateParams" (slice $.Page.Params.reveal_hugo.templates) -}}
{{- end -}} {{- range ($scratch.Get "templateParams") -}}
{{- $scratch.Add "templateParams" (slice $.Page.Params.reveal_hugo.templates) -}} {{- if (ne . nil) -}}
{{- range ($scratch.Get "templateParams") -}} {{- range $key, $value := (index . $template) -}}
{{- if (ne . nil) -}} {{- $scratch.SetInMap "template" $key $value | safeHTMLAttr -}}
{{- range $key, $value := (index . $template) -}}
{{- $scratch.SetInMap "template" $key $value | safeHTMLAttr -}}
{{- end -}}
{{- end -}} {{- 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 -}} {{- end -}}
{{- end -}}
{{- range $sindex, $svalue := $scratch.Get "slides" }}
<section data-noprocess data-shortcode-slide
{{- if $template -}}
{{- 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 -}} {{- range $key, $value := $.Params -}}
{{- if not (in $noOutput $key) -}} {{- if not (in $noOutput $key) -}}
{{- $attrName := cond (in $noPrefix $key) $key (delimit (slice "data" $key) "-") }} {{- $attrName := cond (in $noPrefix $key) $key (delimit (slice "data" $key) "-") }}