If helper expressions

I’ve recently been able to modify a theme to be able display published date & updated date separately, with an old solution from @DavidDarnes & help from @RyanF .

However if a post isn’t modified, the default updated date is usually the same as the published date. This is redundant to show in a post. I was wondering if the updated date could be ignored if the post wasn’t edited.

@DavidDarnes has provided a way, in the original post, for doing this by way of some clever CSS, however it will still show the two dots (bullets). So I was wondering if it was possible to compare the two dates and only render the updated date and the dot if they are different.

I tried to search for it, but couldn’t find a way to do this.

Has anyone does this using “#if” ?

You can use the {{match}} helper for this:

{{published_at}} 
{{#match published_at "!=" updated_at}}
  {{updated_at}}
{{/match}}
4 Likes

Wow! This was incredibly straightforward. Thanks so much.

It was right there in the list of functional helpers in the Ghost docs at Ghost Handlebars Themes - Functional Helpers.

Thanks for your patience in walking me through this.