{{ isset }} How to check variable is empty?

Really appreciate this @stiobhart. I was working on a task to figure out how to pare down my frontmatter, and was trying to figure out the logic for negation. I don’t want to put showpaging: true etc, but rather would add a line only when I want to turn off the default. This post really helped.

This is what I came up with for one of the params hidepaging.

{{ if (not (isset .Params "hidepaging")) }}
<div class="paging">
  {{ if .Prev }}
  <div class="paging-newer">
     <span class="bold">Next Newer: </span>
     <a class="paging-link" href="{{ .Prev.RelPermalink }}">{{ .Prev.Title }}</a>
  </div>
  {{ end }}
  {{ if .Next }}
  <div class="paging-older">
     <span class="bold">Next Older: </span>
     <a class="paging-link" href="{{ .Next.RelPermalink }}">{{ .Next.Title  }}</a>
  </div>
  {{ end }}
</div>
{{ end }}

This code will display the block if that param is not present.

2 Likes