pattern-lab / patternlab-node

The Node version of Pattern Lab
http://patternlab.io
MIT License
2.05k stars 405 forks source link

Broken starter kit Twig Demo #1486

Closed JosefBredereck closed 1 year ago

JosefBredereck commented 1 year ago

I am using Pattern Lab Node v6.0.1 on Windows | Mac | Linux, with Node v16.17.0, using a Twig Edition.

The Twig Demo is currently not working as expected. There are several issues regarding the pattern data and template loading. Pages including templates which include other components are not referencing the data provided by the provided companion JSON file.

Expected Behavior

When I install the starter kit via patternlab install --starterkits @pattern-lab/starterkit-twig-demo it should provide a good stating point with basic components and example pages. Twig files provided under pages should include templates which correctly consume the companion JSON.

For example: The data of homepage.json should correctly be used in pages/homepage.twig which includes templates/homepage.twig

Actual Behavior

I can install the starter kit, but the JSON data from pages is not applied to the output.

Steps to Reproduce

  1. npm create pattern-lab
  2. follow the steps to install twig
  3. patternlab install --starterkits @pattern-lab/starterkit-twig-demo
  4. npm run start
  5. Navigate to pages ⇾ homepage
hadl commented 1 year ago

Tried with: Homepage JSON Data -> Hero

Data is applied correctly but there are some issues with the structure and passing the data in Twig.

  1. hero is an array not an object
  2. including block-hero.twig needs with hero so the data is "flattened"

I saw that, in my installation, the macros namespace was not included in the patternlab-config.json -> error rendering atoms-text-fields. After fixing that there is a notice too: Could not find pattern referenced with partial syntax "_macros/forms.twig" from "./source/_patterns/". which makes sense due to _macros folder outside of "root pattern dir". For my projects i am only registering "custom namespaces" inside the _patterns directory and for e.g. marcos hiding that folder via .md file. Maybe that folder should be moved so the linage would find that import too?

I would take care of that and provide a PR in the next days - If noone is currently working on that, ok?

JosefBredereck commented 1 year ago

Feel free to take on this issue. My experience with twig is close to zero, so I would appreciate if someone could resolve this.