Browse templating

Hello,

I am using the browse functionality and I try to write a template for my own usage. But I do not succeed to retrieve a parameter within a loop Here is the sample of template I want to perform:

<html>
<body>
{{range .Items }}
<a href="{{html .URL}}?token={{.URL.Query.Get "token" }}>
{{end}}
</body>
</html>

I can access from everywhere to .URL.Query.Get but not in the loop. I think it is due to the variable scope, so here is my question, how could I access to this parameter in my loop?

Thank in advance,

Ps: A new caddy lover.

The $ variable will get you the global/original context:

$.URL

See template package - text/template - pkg.go.dev for a full description of how templating works. That should help!

Thank it works like a charm. I think I need to dig a bit more in go template documentation. Thanks for the quick answer.

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