mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
tpl: Allow 'Querify' to take lone slice/interface argument
Querify can now take a lone string/interface slice (with string keys) as a parameter, or multiple string parameters, to build URL queries. Querify earlier used 'Dictionary' to add key/value pairs to a map to build URL queries. Changed to dynamically generate ordered key/value pairs. Cannot take string slice as key (earlier possible due to Dictionary). Added tests and benchmarks for querify. Closes #6735
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
504c78da4b
commit
c46fc838a9
@@ -122,6 +122,10 @@ func init() {
|
||||
`<a href="https://www.google.com?{{ (querify "q" "test" "page" 3) | safeURL }}">Search</a>`,
|
||||
`<a href="https://www.google.com?page=3&q=test">Search</a>`,
|
||||
},
|
||||
{
|
||||
`{{ slice "foo" 1 "bar" 2 | querify | safeHTML }}`,
|
||||
`bar=2&foo=1`,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user