Pipe syntax with `if` not working

I’m testing hugo out, and I’m really hoping to use it for my current project.

I can’t seem to get pipe syntax to work with a conditional. This snippet comes straight from the docs:

{{ eq 1 1 | if }} Same {{ end }}

But for me it triggers an error:

ERROR: 2015/09/02 template: book/single.html:37: unexpected <if> in command
ERROR: 2015/09/02 Error while rendering page book/book/test.md: html/template: "book/single.html" is an incomplete template

Has anyone else encountered this? Do I need to configure something? I’m using v0.14.

On a sidenote, the normal if syntax works fine:

{{ if eq 1 1 }} Same {{ end }}

I also tried using the pipe like the example in the documentation with the same error.

Pipes are only used with commands. if is an “action,” not a command.

I appreciate the response, but could you please elaborate a little more.

I don’t know Go but I have read the Go template documentation. Are functions like if , with , range considered actions. If so what is designated as a command. Is it just simple stuff like math equations or simple methods like title or upper or is there a more concrete definition that I’m not seeing.

Also if that is the case than the example provided in the hugo docs is completely wrong.

Again thanks for the response!

Yes, you understand it. Here’s the builtin-in “commands” with Go templates (doesn’t include Hugo add-ons). I only call them “commands” because that’s what the Go docs use. I prefer to call them functions or funcs.

I’m assuming the problem in the docs is here, right?

Thanks for the links. Definitely helps clear things up. Yes the problem in the docs is there.

https://github.com/spf13/hugo/issues/2787