Skip to content

proposal: text/template: allow multiple actions within {{}} #46588

@atishay

Description

@atishay

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

1.16.4

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOOS="darwin"

What did you do?

The desire is to be able to place multiple commands in a Go text template. We already have newlines supported ( #29770 ). If we get multiple commands using any separator, we can simplify templates with multiple mustaches one after the other.

An example using Hugo (with a semi-colon as a separator, can be anything):

{{
      with site.Title;
          printf "%s" (. | humanize);
     else;
          printf "No title";
     end;
}}

equivalent to:

{{with site.Title}}
    {{printf "%s" (. | humanize)}}
{{else}}
  {{printf "No title"}}
{{end}}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions