Skip to content

Conversation

@vvuk
Copy link
Contributor

@vvuk vvuk commented May 26, 2025

This is a sort of "hey, wouldn't it just work if.." WIP PR. It allows specifying variables to [include] statements, e.g.:

[include foo.cfg]
FOO: bar
THING: 2

and then foo.cfg can use jinja directives with {!% %!} {! !} (with the added !) to do templating and variable expansion that's resolved directly at include time, e.g. foo.cfg:

[somesection]
option: name-{! FOO !}
{!% if THING == 2 %!}
something: else
{!% endif %!}

The entire included file is treated as a template and rendered before being passed to the parser. Variables get maintained in an include chain -- if foo.cfg includes a file, FOO and THING will be available there too.

I still need to see how this interacts with SAVE_CONFIG (if at all). All this enables things like:

[include board-ebb36.cfg]
mcu_name: toolhead0
mcu_path: /dev/serial/....

[include board-ebb36.cfg]
mcu_name: toolhead1
mcu_path: /dev/serial/....

Checklist

  • pr title makes sense
  • added a test case if possible
  • if new feature, added to the readme
  • ci is happy and green

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant