aleksip / plugin-data-transform

Data Transform Plugin for Pattern Lab PHP
GNU General Public License v2.0
34 stars 10 forks source link

Pattern state and data inheritance #22

Closed arismag closed 5 years ago

arismag commented 5 years ago

Hello,

First of all cograts for the great plugin ;)!

I couldn't find a similar issue so.. In a current a project we tried to use pattern states with data-transform plugin and it seems that it's not working as expected(?).

More specifically, we tried to include a card pattern (file name card@inintegration.twig) inside another as shown below:

{% include '@components/00-common/card/card@inintegration.twig' %}

The pattern's markup is included but it does not inherit data from card.yml file.

Any ideas on this one?

Thanks!

arismag commented 5 years ago

UPDATE:

I think I figured out what is happening. It seems that the plugin is searching for a data file with the same base name as of twig file.

In this case, the base name of the twig file is card@inintegration so it will look for the card@inintegration.yml.

Indeed, when I changed card.yml to card@inintegration.yml data inherits correctly.

Is there hint for a fix on this?

aleksip commented 5 years ago

Hi, and thanks!

Data Transform Plugin does not actually look for the data files, this is done by Pattern Lab core. And the way core works is that pattern-specific data files must have the same base name as the pattern, like you found out. Here is the relevant core documentation: https://patternlab.io/docs/data-pattern-specific.html