How to display front matter content conditionally only if it is present?

I am using custom front matter variables in my posts files and displaying them in the List pages as well, however at times, certain posts might not actually have the requisite data stored in those variables and might be empty.

I require the list pages to render the front matter variables and associated heading for those specific posts only if there exists data stored inside of those variables.

For eg. I have an ‘expiry’ variable which is displayed alongwith posts in lists page, however some posts do not have any data stored in them. How to render the list page conditionally so as to skip displaying associated text for this variable if the post doesn’t hold any data for this variable.

How can I achieve this ?

Something like:

{{ range site.RegularPages }}
  <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
  {{ with .Params.expiry }}
    Expiry: {{ . }}
  {{ end }}
{{ end }}