Skip to content

tpl/collections: Allow querify to accept a map argument #13131

@jmooring

Description

@jmooring

The collections.Querify template function accepts either of the following argument forms:

{{ collections.Querify "a" 1 "b" 2 }}         --> a=1&b=2
{{ collections.Querify (slice "a" 1 "b" 2) }} --> a=1&b=2

But it would convenient if we could do:

{{ collections.Querify (dict "a" 1 "b" 2) }}

For example, in our embedded youtube shortcode we:

  1. Build a map of parameters

  2. Convert the map into a slice with this construct:

    {{ range $k, $v := $params }}
      {{ $s = $s | append $k }}
      {{ $s = $s | append $v }}
    {{ end }}
    
  3. Pass the slice to collections.Querify

It would be more elegant if we could remove step 2 above.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions