I'm writing a simple Go template. Specifically, it's a Hugo shortcode
that includes a page resource's content into a page, skipping a few
lines.
Both of these approaches work (but piping the output of `after` into
`delimit` doesn't work, because `delimit` takes its arguments in the
wrong order).
Should I prefer one over the other? Which of these (if either) would
be considered idiomatic?
1.
{{- $resource := .Page.Resources.Get $path -}}
{{- $lines := split $resource.Content "\n" | after $skip_lines -}}
{{- delimit $lines "\n" | safeHTML -}}
2.
{{- with .Page.Resources.Get $path -}}
{{- with split .Content "\n" | after $skip_lines -}}
{{- delimit . "\n" | safeHTML -}}
{{- end -}}
{{- end -}}
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/golang-nuts/CAAR6NGnYSTi1Zrj5RkJmFZHuX%2Bksrwz5kgAUGSzSB0auCw4UsA%40mail.gmail.com.