Template actions: concatenate arguments

Hi,

I’m searching a way to concatenate strings around a function in a template.

I’m trying to get working something like that:
{{.Include "path/to/"+(.URL.Query.Get "lang")+"/file.html"}}

eg. to include the file /path/to/en/file.html, depending on the URL Query parameter (‘lang’ in this example).

Is it possible?

Many thanks in advance.

You can use the print and printf functions. :slight_smile: template package - text/template - pkg.go.dev

Thanks Matt :wink:

One possible solution:
{{.Include (print "/path/to/" (.URL.Query.Get "lang") "/file.html")}}

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