github.com/wfusion/gofusion@v1.1.14/common/infra/watermill/docs/layouts/shortcodes/load-snippet.html (about)

     1  {{ $file := (.Get "file") }}
     2  {{ $content := readFile $file }}
     3  
     4  {{ $start_line := (.Get "start_line") | default "0" }}
     5  {{ $end_line := (.Get "end_line") | default "0" }}
     6  
     7  {{ $has_start_line := (ne $start_line "0") }}
     8  {{ $has_end_line := (ne $end_line "0") }}
     9  
    10  {{ $lines := slice }}
    11  
    12  {{ $linkFile := $file }}
    13  {{ $repo := "watermill" }}
    14  
    15  {{ if in $file "src-link/watermill-" }}
    16      {{ $repo = index (findRE "watermill-[a-z]+" $linkFile) 0 }}
    17      {{ $linkFile = replace $linkFile $repo "" }}
    18      {{ $linkFile = replace $linkFile "src-link//" "" }}
    19  {{ else if in $linkFile "src-link/" }}
    20      {{ $linkFile = replace $linkFile "src-link/" "" }}
    21  {{ else }}
    22      {{ $linkFile = print "docs/content/" $linkFile }}
    23  {{ end }}
    24  
    25  <small class="smaller">Full source: [{{ $linkFile }}](https://github.com/ThreeDotsLabs/watermill/tree/master/{{ $linkFile }})</small>
    26  
    27  {{ range $elem_key, $elem_val := split $content "\n" }}
    28      {{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)))}}
    29          {{ $lines = $lines | append $elem_val }}
    30      {{ end }}
    31  {{ end }}
    32  
    33  
    34  {{ highlight (delimit $lines "\n") (.Get "type" | default "go") "" }}