snapshot of https://github.com/ThreeDotsLabs/watermill.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
master / ci (push) Failing after 0s
Some checks failed
master / ci (push) Failing after 0s
This commit is contained in:
37
docs/layouts/shortcodes/load-snippet.html
Normal file
37
docs/layouts/shortcodes/load-snippet.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{{ $file := (.Get "file") }}
|
||||
{{ $content := readFile $file }}
|
||||
|
||||
{{ $start_line := (.Get "start_line") | default "0" }}
|
||||
{{ $end_line := (.Get "end_line") | default "0" }}
|
||||
|
||||
{{ $has_start_line := (ne $start_line "0") }}
|
||||
{{ $has_end_line := (ne $end_line "0") }}
|
||||
|
||||
{{ $lines := slice }}
|
||||
|
||||
{{ $linkFile := $file }}
|
||||
{{ $repo := "watermill" }}
|
||||
|
||||
{{ if in $file "src-link/watermill-" }}
|
||||
{{ $repo = index (findRE "watermill-[a-z]+" $linkFile) 0 }}
|
||||
{{ $linkFile = replace $linkFile $repo "" }}
|
||||
{{ $linkFile = replace $linkFile "src-link//" "" }}
|
||||
{{ else if in $linkFile "src-link/" }}
|
||||
{{ $linkFile = replace $linkFile "src-link/" "" }}
|
||||
{{ else }}
|
||||
{{ $linkFile = print "docs/content/" $linkFile }}
|
||||
{{ end }}
|
||||
|
||||
{{ range $elem_key, $elem_val := split $content "\n" }}
|
||||
{{if and (or (not $has_start_line) (ge (add $elem_key 1) ($start_line | int))) (or (not $has_end_line) (le (add $elem_key 1) ($end_line | int)))}}
|
||||
{{ $lines = $lines | append $elem_val }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<div class="expressive-code">
|
||||
<figure class="frame not-content">
|
||||
{{ transform.Highlight (delimit $lines "\n" | safeHTML) (.Get "type" | default "go") }}
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<small class="smaller">Full source: [{{ $linkFile }}](https://github.com/ThreeDotsLabs/watermill/tree/master/{{ $linkFile }})</small>
|
||||
Reference in New Issue
Block a user