Is there a better way to trim spaces/empty lines generated via template actions

With reference

          {{ range $index, $page := $group.pages -}}
              {{ $pageSlug := $page.title | urlize -}}
              {{ $isActivePage := eq $urlPageSlug $pageSlug -}}
              {{ $href := printf "%s%s/%s/" $.Site.Home.Permalink $.Section $pageSlug -}}
              {{ $hrefPageTitle := $page.title -}}
              {{ if and (eq $index 0) $group.replaceFirstPageTitle -}}
                {{ $hrefPageTitle := $group.replaceFirstPageTitle -}}
              {{ end -}}
            <li>
              <a class="{{ if $isActivePage }}active{{ end }}" href="{{ $href }}">{{ $hrefPageTitle }}</a>
            </li>
         {{ end -}}

To avoid empty lines generated by {{ code }} template action blocks, I’ve just change each to {{ code -}}. Is this correct or is there any better way to do this?

if you want better readability for your generated files while in development that is the way to go.

for production usually --minify is used but nit readable

there are some config settings for minify. maybe you can play around with them to achieve something in between…never tried

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.