Add support for slide templates
This commit is contained in:
parent
e6e2234960
commit
8b76bd9182
1 changed files with 20 additions and 5 deletions
|
@ -1,22 +1,37 @@
|
||||||
{{- .Scratch.Set "slides" slice -}}
|
{{- $scratch := .Scratch -}}
|
||||||
|
{{- $scratch.Set "slides" slice -}}
|
||||||
{{- if len .Inner -}}
|
{{- if len .Inner -}}
|
||||||
{{- .Scratch.Add "slides" .Inner -}}
|
{{- $scratch.Add "slides" .Inner -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- $content := .Get "content" -}}
|
{{- $content := .Get "content" -}}
|
||||||
{{- if $content -}}
|
{{- if $content -}}
|
||||||
{{- $lookup := split $content "." }}
|
{{- $lookup := split $content "." }}
|
||||||
{{- $html := index .Page.Site.Data (index $lookup 0) (index $lookup 1) | markdownify -}}
|
{{- $html := index .Page.Site.Data (index $lookup 0) (index $lookup 1) | markdownify -}}
|
||||||
{{- $slides := split $html "<hr />" -}}
|
{{- $slides := split $html "<hr />" -}}
|
||||||
{{- $scratch := .Scratch -}}
|
|
||||||
{{- range $slides -}}
|
{{- range $slides -}}
|
||||||
{{- $scratch.Add "slides" . -}}
|
{{- $scratch.Add "slides" . -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- $params := . -}}
|
{{- $params := . -}}
|
||||||
{{- $noPrefix := slice "id" -}}
|
{{- $noPrefix := slice "id" -}}
|
||||||
{{- $noOutput := slice "content" -}}
|
{{- $noOutput := slice "content" "template" -}}
|
||||||
{{- range .Scratch.Get "slides" }}
|
{{- range $scratch.Get "slides" }}
|
||||||
<section data-noprocess data-shortcode-slide
|
<section data-noprocess data-shortcode-slide
|
||||||
|
{{- $template := $params.Get "template" -}}
|
||||||
|
{{- if $template -}}
|
||||||
|
{{- $templateParams := slice $.Site.Params.reveal_hugo.templates ($.Site.GetPage $.Page.Section).Params.reveal_hugo.templates $.Page.Params.reveal_hugo.templates -}}
|
||||||
|
{{- range $templateParams -}}
|
||||||
|
{{- if (ne . nil) -}}
|
||||||
|
{{- range $key, $value := (index . $template) -}}
|
||||||
|
{{- $scratch.SetInMap "template" $key $value | safeHTMLAttr -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- range $key, $value := ($scratch.Get "template") }}
|
||||||
|
data-{{ $key | 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) "-") }}
|
||||||
|
|
Loading…
Reference in a new issue