Skip to content

Make data inheritance work for multilevel file includes #9

@vikalp-sajwan

Description

@vikalp-sajwan

Hi @dmolsen, firstly thanks for your plugin.
I am using this plugin in project and facing an issue with data-inheritance. This does not work for multilevel file includes, when the sub-included files are lexicographically greater.
This could be solved using numeric prefix in filenames, but I would really like to avoid that.

For eg. let say we have three patterns in atoms directory:

  • a.twig

    This is a.twig {{ data1 }} {% include 'atoms-b' %}
  • a.json

    { "data1": "hello from A" }
  • b.twig

    This is b.twig {{ data2 }} {% include 'atoms-c' %}
  • b.json

    { "data2": "hello from B" }
  • c.twig

    This is c.twig {{ data3 }}
  • c.json

    { "data3": "hello from C" }

In this case, pattern a will inherit data for only first level include i.e for b, and not for the c. As b is processed later by the plugin.

This can be easily solved by recursively processing the patterns with lineage first, keeping track of the processed patterns at the same time.

Let me know what you think about this, I'll be happy to submit a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions