Skip to content

text/template: weird template block parameters precedence #33265

@sylr

Description

@sylr

What version of Go are you using (go version)?

$ go version
go1.12.7. 

Does this issue reproduce with the latest release?

Yes

What did you do?

https://play.golang.org/p/zPTLk2G-iAP

I'd like to gzip and base64 the output of the template so I've written this:

{{- define "pwet" }}
My string
{{- end}}
{{ template "pwet" . | stringToGzipedBase64 }}

This seems to be syntactically right but the way it's interpreted is not what I expected

{{ template "pwet" . | stringToGzipedBase64 }} // What I wrote
{{ template "pwet" (. | stringToGzipedBase64) }} // How it's interpreted by the parser
{{ (template "pwet" .) | stringToGzipedBase64 }} // How I think it should be interpreted 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions