Visitar URL original
Allow to use keyword arguments in plugins called within a template · Issue #559 · inmanta/std · GitHub
Skip to content

Allow to use keyword arguments in plugins called within a template #559

Open

Description

@edvgui

Consider the following model

std::print(std::template("/ip.j2", net="192.168.0.0/24"))

and the following template:

{{ net | std.ipindex(1, keep_prefix=true) }}

The compiler will fail with the given exception:

TypeError: _get_template_engine.<locals>.curywrapper.<locals>.safewrapper() got an unexpected keyword argument 'keep_prefix'

It should be possible to call these plugins this way. The config module already does it, this is a workaround to the original model:

std::print(config::get_template_value_as_string({"path": "template:///ip.j2}", "path", net="192.168.0.0/24"))

Activity

  1. changed the title [-]All to use keyword arguments in plugins called within a template[/-] [+]Allow to use keyword arguments in plugins called within a template[/+] on Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerenhancementNew feature or requestusabilityThis ticket is related to improved usability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions