Partial stopped working after update from 0.61 to 0.72

UPDATE:
The solution is
{{ if or (isset .Params "challenges") (isset .Params "features") }}
or
{{ if or (.Page.Param "challenges") (.Page.Param "features") }}


I have the following line in one of my partials:
{{ if or ((.Page.Param "challenges") (.Page.Param "features")) }}

It checks for the existence of the challenges or features param in the frontmatter. In 0.61, it works.
In 0.72, I get the following error:

execute of template failed: template: partials/use-cases/relationships.html:3:14: executing "partials/use-cases/relationships.html" at <(.Page.Param "challenges") (.Page.Param "features")>: can't give argument to non-function .Page.Param "challenges"

How do I need to modify this to make it work?
I tried including .Page.Param "challenges" and .Params.challenges in the article template and they both print the contents of the param, but none works in the partial.
I tried:

  • {{ if or ((isset .Params "challenges") (isset .Params "features")) }}
  • {{ if or ((isset .Params.challenges) (isset .Params.features)) }}

and I also end up with can't give argument to non-function isset .Params.challenges

How do I make this work again?

There was a bug fix in a recent Go template version that now corrrectly reports the above as an error.

In short: Parens expressions can never be a function and should never have argument(s).

I assume the above should be:

{{ if or (.Page.Param "challenges") (.Page.Param "features") }}
1 Like

Yes, this helped :slight_smile: Thanks!

It even works in a mix :smiley:
{{ if or (.Page.Params.challenges) (.Page.Param "features") }}

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