Skip to content

Commit

Permalink
feat(config-toggle): allow wrapping code with delimiters (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Dec 8, 2023
1 parent 980bb9f commit 33ed9bb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions layouts/partials/bootstrap/config-toggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
{{- $style := "tabs" }}
{{- $fill := false }}
{{- $title := "" }}
{{- $delimiter := false }}
{{- if .IsNamedParams }}
{{- with .Get "filename" }}{{ $filename = . }}{{ end }}
{{- with .Get "langs" }}{{ $langs = split . "," }}{{ end }}
{{- with .Get "style" }}{{ $style = . }}{{ end }}
{{- with .Get "fill" }}{{ $fill = . }}{{ end }}
{{- with .Get "title" }}{{ $title = . }}{{ end }}
{{- with .Get "delimiter" }}{{ $delimiter = . }}{{ end }}
{{- else }}
{{- with .Get 0 }}{{ $filename = . }}{{ end }}
{{- with .Get 1 }}{{ $langs = split . "," }}{{ end }}
Expand Down Expand Up @@ -46,9 +48,17 @@
<div class="tab-content">
{{- $src := $.Inner | htmlUnescape | transform.Unmarshal }}
{{- range $i, $lang := $langs -}}
{{- $lang = lower $lang }}
{{- $id := printf "code-toggle-%s-%s" $idPrefix $lang -}}
{{- $code := $src | transform.Remarshal $lang -}}
{{- $code = replaceRE "\n+" "\n" $code -}}
{{- if $delimiter }}
{{- if eq $lang "toml" }}
{{- $code = printf "+++\n%s+++\n" $code }}
{{- else if eq $lang "yaml" }}
{{- $code = printf "---\n%s---\n" $code }}
{{- end }}
{{- end }}
<div
class="tab-pane fade{{ cond (eq $i 0) ` show active` `` }}"
id="{{ $id }}"
Expand Down

0 comments on commit 33ed9bb

Please sign in to comment.