Skip to content

Dictionary Operations documentation example results with error #2465

@SpaceCowboyMax

Description

@SpaceCowboyMax

Description

Documentation example

- echo "Database {{.CONFIG | get "database"}}"

Gives the next error:

template: :1:31: executing "" at <"database">: can't handle "database" for arg of type map[string]interface {}

It appears that the argument order of the get and hasKey functions in the documentation example may be incorrect or bugged.

those changes made in example provides a correct result

cmds:
  - echo "Database {{"database" | get .CONFIG}}"
  - echo "Keys {{.CONFIG | keys}}"
  - echo "Has SSL {{"ssl" | hasKey .CONFIG}}"
  - echo "{{dict "env" "prod" "debug" false}}"

Version

3.45.3

Operating system

dnf/linux_amd64

Experiments Enabled

No response

Example Taskfile

# https://taskfile.dev

version: '3'

tasks:
  dict:
    vars:
      CONFIG:
        map:
          database: postgres
          port: 5432
          ssl: true
    cmds:
      - echo "Database {{.CONFIG | get "database"}}"
      - echo "Keys {{.CONFIG | keys}}"
      - echo "Has SSL {{.CONFIG | hasKey "ssl"}}"
      - echo "{{dict "env" "prod" "debug" false}}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: docsChanges related to documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions