Skip to content

How to escape the ending * (asterisk) in the value of template variables? #126

@hsheng

Description

@hsheng

python 3.8 and ttp-0.9.2

The input:

    interfaces {
        ge-* {
            unit * {
                forwarding-class BE;
            }
        }
        xe-* {
            unit * {
                forwarding-class BE;
            }
        }
    }

The template:

    <group name="interfaces">
    interfaces { {{ _start_ }}

        <group name="interface-set.{{ interface-set}}">
        interface-set {{ interface-set | _start_ }} {
            excess-bandwidth-share {{ excess-bandwidth-share | _line_ }};
            output-traffic-control-profile {{ output-traffic-control-profile }};
        } {{ _end_ }}
        </group>

        <group name="interface.{{ interface }}">
        {{ interface | _start_ }} {
            apply-groups {{ apply-groups }};
            shaping-rate {{ shaping-rate}};
            output-traffic-control-profile {{ output-traffic-control-profile }};

            <group name="unit.{{ unit }}">
            unit {{ unit | _start_ }} {
                apply-groups {{ apply-groups }};
                output-traffic-control-profile {{ output-traffic-control-profile }};
                <group name="classifiers*">
                classifiers { {{ _start_ }}
                    {{ classifier | _line_ }};
                } {{ _end_ }}
                </group>
            } {{ _end_ }}
            </group>

        } {{ _end_ }}
        </group>

    } {{ _end_ }}
    </group>

The expected result:

{ 
    "interfaces": {
        "interface": {
            "ge-*": {
                "unit": {
                    "*": {
                        "forwarding-class": "BE"
                    }
                }
            },
            "xe-*": {
                "unit": {
                    "*": {
                        "forwarding-class": "BE"
                    }
                }
            },
        }
}

The actual result:

{
    'interfaces': {
        'interface': {
            'ge-': [
                {
                    'unit': {
                        '': []
                    }
                }
            ], 
            'xe-': [
               {
                   'unit': {
                       '': []
                   }
               }
            ],
        } 
    }
}

How to escape the ending * (asterisk) in the template attribute value?

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