feat(shortcode): add script shortcode (#359)

This commit is contained in:
Dillon
2020-05-15 17:43:04 +08:00
committed by GitHub
parent c5a0ec61c9
commit d3d2d751ec
18 changed files with 132 additions and 39 deletions

View File

@@ -0,0 +1,2 @@
{{- $scriptArr := (.Page.Scratch.Get "this").scriptArr | default slice -}}
{{- $scriptArr | append (trim .Inner "\n") | .Page.Scratch.SetInMap "this" "scriptArr" -}}

View File

@@ -1,5 +1,5 @@
{{- $content := .Inner | .Page.RenderString -}}
{{- $id := dict "content" $content "scratch" .Page.Scratch | partial "function/id.html" -}}
{{- $id := dict "scratch" .Page.Scratch | partial "function/id.html" -}}
{{- $tag := .Get 1 | default "div" -}}
{{- printf `<%s id="%s">%s</%s>` $tag $id $content $tag | safeHTML -}}