Data Templates & if else statements, date formatting

I’m struggling to figure out how to do the following things:

  • write an if/else statement on booleans from values in my data template
  • get my date format to shorten (I’ve tried .Format and .dateFormat)

if else

I’d like to be able to display friendlier text or an image like :white_check_mark: if supported = true. Is this possible?

title = "Feature Name"
hasFeatureFlag = false


 [[platforms]]
   platformName = "Platform A"
   supported = true
   firstSupportedVersion = "N/A"
   firstReleaseDate = 2020-01-01

date format

I’ve tried the following:

{{.firstRleaseDate.Format "January 2, 2006" }}
{{ dateFormat "Monday, Jan 2, 2006" ".firstReleaseDate"}}

I’m not sure I understand your question. Are you asking how to use if/else statements?

{{ if .supported }}
  yes
{{ else }}
  no
{{ end }}
{{ dateFormat "Monday, Jan 2, 2006" .firstReleaseDate}}

You can read more about data templates here: https://gohugo.io/templates/data-templates/

this actually helped. i didnt realize if/else would read .supported as true or false automatically with no instructions haha. thank you!