Reduce whitespace in templates and avoid polluting the page scratch
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
@@ -1,40 +1,41 @@
|
||||
{{- $source := (readFile (printf "code/%s" (.Get 1))) -}}
|
||||
{{- $allLines := split $source "\n" -}}
|
||||
{{- $scratch := newScratch -}}
|
||||
{{- if not (eq (int (.Get 2)) 1) -}}
|
||||
{{- .Scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) -}}
|
||||
{{- $scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) -}}
|
||||
{{- else -}}
|
||||
{{- .Scratch.Set "remLines" $allLines -}}
|
||||
{{- $scratch.Set "remLines" $allLines -}}
|
||||
{{- end -}}
|
||||
{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "remLines") -}}
|
||||
{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) ($scratch.Get "remLines") -}}
|
||||
|
||||
{{- if (.Get 4) -}}
|
||||
{{- .Scratch.Set "opts" (printf ",%s" (.Get 4)) -}}
|
||||
{{- $scratch.Set "opts" (printf ",%s" (.Get 4)) -}}
|
||||
{{- else -}}
|
||||
{{- .Scratch.Set "opts" "" -}}
|
||||
{{- $scratch.Set "opts" "" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if (.Get 5) -}}
|
||||
{{- .Scratch.Set "hidden" (.Get 5) -}}
|
||||
{{- $scratch.Set "hidden" (.Get 5) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1)) -}}
|
||||
{{- partial "linerangestr.html" (dict "scratch" .Scratch "from" (.Get 2) "to" (.Get 3)) -}}
|
||||
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1)) -}}
|
||||
{{- partial "linerangestr.html" (dict "scratch" $scratch "from" (.Get 2) "to" (.Get 3)) -}}
|
||||
|
||||
{{- with (.Scratch.Get "hidden") -}}
|
||||
<details><summary>{{ . | markdownify }}</summary>
|
||||
{{- with ($scratch.Get "hidden") -}}
|
||||
<details><summary>{{- . | markdownify -}}</summary>
|
||||
{{- end -}}
|
||||
{{- $groupconfig := dict
|
||||
"url" (.Scratch.Get "bestUrl")
|
||||
"basePath" (.Scratch.Get "bestPath")
|
||||
"url" ($scratch.Get "bestUrl")
|
||||
"basePath" ($scratch.Get "bestPath")
|
||||
"path" (.Get 1)
|
||||
"comment" (.Scratch.Get "comment")
|
||||
"comment" ($scratch.Get "comment")
|
||||
"code" (delimit $lines "\n")
|
||||
"firstLine" (int (.Get 2))
|
||||
"lastLine" (int (.Get 3))
|
||||
"language" (.Get 0)
|
||||
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) (.Scratch.Get "opts"))
|
||||
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) ($scratch.Get "opts"))
|
||||
-}}
|
||||
{{- partial "highlightgroup.html" $groupconfig -}}
|
||||
{{- with (.Scratch.Get "hidden") -}}
|
||||
{{- with ($scratch.Get "hidden") -}}
|
||||
</details>
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user