Skip to content

Navigation Menu

Sign in
Sign up

Add Jinja2 templating to config #1882

luke-hackwell started this conversation in General
Discussion options

I understand that the exporter config supports Jinja2 templating. I have a few use cases where this would be useful for the main config, such as conditionally adding resources/drivers, or populating a resource with a dynamic list. This can't be achieved using the !template feature.

Is there a reason that Jinja2 templating hasn't been implemented for the main config? Would you accept a PR for this?

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

What exactly do you want to template? Maybe an external template generation would be more suitable here?

You must be logged in to vote
1 reply
Comment options

I would like to be able to template based on env vars, for example to create key value pairs within a resource:

Resource:
# for pair in env["LG_MAP"].split(",")
# set key, value = pair.split("=", 1)
 {{ key }}: {{ value }}
# endfor

Where LG_MAP='key1=value1,key2=value2'
Or this could be used to conditionally define a resource base don an env var. For the implementation we could pass env vars prefixed with LG_ to the templating engine?

I've considered externally generating this but in our case it would be much more readable to have the templating be in the Labgrid config, otherwise there's some complicated indirection that hurts readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Converted from issue

This discussion was converted from issue #1874 on June 03, 2026 12:23.

AltStyle によって変換されたページ (->オリジナル) /