Skip to content

Strange behavior of a nested group when the _line_ indicator matches data but corresponding placeholder variable does not #135

@VeryVVell

Description

@VeryVVell

Hi, Denis!

Given with data:

[Slot1]
[Main]
[Board properties]
serial = serial10

[Board11]
[Board properties]
serial = serial11

[Slot2]
[Main]
[Board properties]
serial = serial20

[Board21]
[Board properties]
serial = serial21

and this template:

<group name='{{ slot }}'>
[Slot{{ slot | prepend('Slot') }}]
    <group name='boards'>
[{{ _line_ }}]
    </group>
</group>

I get the results as expected, where each value in square brackets is matched for the nested group (a bit more processing required to filter 'Board properties' but it is omitted for simplicity):

[[{'Slot1': {'boards': [{'_line_': 'Main'},
                        {'_line_': 'Board properties'},
                        {'_line_': 'Board11'},
                        {'_line_': 'Board properties'}]},
   'Slot2': {'boards': [{'_line_': 'Main'},
                        {'_line_': 'Board properties'},
                        {'_line_': 'Board21'},
                        {'_line_': 'Board properties'}]}}]]

But if I replace _line_ indicator with variable name I get nothing:

<group name='{{ slot }}'>
[Slot{{ slot | prepend('Slot') }}]
    <group name='boards'>
[{{ var }}]
    </group>
</group>

[[{}]]

More over, adding PHRASE filter works as expecting

<group name='{{ slot }}'>
[Slot{{ slot | prepend('Slot') }}]
    <group name='boards'>
[{{ var | PHRASE }}]
    </group>
</group>

[[{'Slot1': {'boards': [{'var': 'Board properties'},
                        {'var': 'Board properties'}]},
   'Slot2': {'boards': [{'var': 'Board properties'},
                        {'var': 'Board properties'}]}}]]

But ORPHRASE filter (that is combination of either PHRASE or WORD) brings nothing again. It expects that result should include 'Board properties' and 'Main' at least.

<group name='{{ slot }}'>
[Slot{{ slot | prepend('Slot') }}]
    <group name='boards'>
[{{ var | ORPHRASE }}]
    </group>
</group>

[[{}]]

I investigated the docs from the left to the right and from the right to the left but still have no idea why ttp does so.

Environment:
Python 3.9.16
ttp 0.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions