Skip to content

Handle Nested Iterators and In-Line For Block#30

Open
Teagan42 wants to merge 3 commits intoArtyMaury:masterfrom
constructorfleet:patch-1
Open

Handle Nested Iterators and In-Line For Block#30
Teagan42 wants to merge 3 commits intoArtyMaury:masterfrom
constructorfleet:patch-1

Conversation

@Teagan42
Copy link
Copy Markdown

Description

The current REGEX pattern for matching Jinja for blocks is too greedy. If a user defines a for block that is in line with the body, the pattern will not appropriately match the for block loop variable or the list variable.

Example:

#vars.yml
my_service:
  description: Some Service
  requires:
    - data.mount
    - docker.service
    - other.service
  exec: /usr/bin/docker start -a test1-container
[Unit]
Description={{ my_service.description }}
After={% for service in my_service.requires %}{{ service }} {% endfor %}

[Service]
ExecStart={{ my_service.exec }}

Changes

  • Narrow REGEX pattern to properly parse loop variable and list variable
  • Resolve nested list variable, i.e. {% for x in item.value.requires %}

@ArtyMaury
Copy link
Copy Markdown
Owner

Never used it inline indeed. Thanks for the contribution!
Could you just add an entry to the Changelog please?

@tlourey
Copy link
Copy Markdown

tlourey commented Jan 12, 2024

Hi @Teagan42 and @ArtyMaury,

I really need this feature.

@Teagan42 could you update the change log with the changes you put int the PR comment, or give me access to your fork so I can do it for you?
@ArtyMaury if @Teagan42 can't give me access or make the changes, could you perhaps use the lines in the PR comment for the change log?

Thanks heaps!

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.

3 participants