38 lines
1.3 KiB
HTML
38 lines
1.3 KiB
HTML
{{ $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>
|