Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Longhand includes break lineage #36

Open
jayfreestone opened this issue Jan 23, 2017 · 13 comments
Open

Longhand includes break lineage #36

jayfreestone opened this issue Jan 23, 2017 · 13 comments

Comments

@jayfreestone
Copy link

I'm not sure if this is an issue with the twig extension or the core Patternlab library, but using 'longhand' includes with full paths (i.e. not the fuzzy shorthand syntax) seems to break pattern lineage.

Patterns which consist of longhand includes don't show their lineage, and also don't work with the Data Inheritance Plugin, which expects to receive lineage information.

This doesn't seem to be documented as a limitation of using longhand, is this a known issue? Unfortunately using PL in production necessitates the use of full-path includes.

@sghoweri
Copy link

sghoweri commented May 14, 2017

@jayfreestone - Unfortunately, this is a well known issue that @EvanLovely and I have discussed quite a bit in the last couple weeks.

While I'm not sure if this will completely fix the Data Inheritance issues, for what it's worth, we think we have a general fix for the terribly broken lineage functionality in the works:
Part 1 of our fix, an update to the Twig regex (which is tied in with how Pattern Lab identifies template lineages), is already merged in on our drupal-pattern-lab/patternengine-php-twig fork

Once Part 2's PR (drupal-pattern-lab/patternlab-php-core#5) is merged in downstream, at least basic lineage behavior should be back to normal (w/ embeds and extends also getting picked up by lineages as well now). It might also fix data inheritance.... (or help us get closer to fixing that as well) -- Fingers crossed!

@tanc
Copy link

tanc commented Jun 7, 2017

@sghoweri I've just been testing your work, or at least trying to (not very experienced with pattern lab). Using the non-forked repository and aleksip/plugin-data-transform I was able to have data inheritance working correctly but only with the shorthand syntax. As @jayfreestone pointed out in production we need the long syntax. Which led me to here and your forked repo and new commit.

I switched to the forked repo and cloned the commit referenced in your 'Part 2'. I then tried the long syntax but its not picking up inherited data as it should. I've tried both with aleksip/plugin-data-transform and pattern-lab/plugin-data-inheritance but no joy with either. Any guidance?

@tanc
Copy link

tanc commented Jun 7, 2017

I realised I had the old regex in my config.yml so I updated it to the new one. Now I'm seeing a lot of errors like:

Warning: array_unique() expects parameter 1 to be array, null given in /Users/tanc/Sites/agile_profile/l.jmp/gitroot/web/themes/custom/jmp_theme/pattern-lab/vendor/drupal-pattern-lab/core/src/PatternLab/PatternData/Helpers/LineageHelper.php on line 220
NULL
PHP Notice:  Undefined offset: 3 in /Users/tanc/Sites/agile_profile/l.jmp/gitroot/web/themes/custom/jmp_theme/pattern-lab/vendor/drupal-pattern-lab/core/src/PatternLab/PatternData/Helpers/LineageHelper.php on line 220
PHP Warning:  array_unique() expects parameter 1 to be array, null given in /Users/tanc/Sites/agile_profile/l.jmp/gitroot/web/themes/custom/jmp_theme/pattern-lab/vendor/drupal-pattern-lab/core/src/PatternLab/PatternData/Helpers/LineageHelper.php on line 220
PHP Notice:  Undefined offset: 3 in /Users/tanc/Sites/agile_profile/l.jmp/gitroot/web/themes/custom/jmp_theme/pattern-lab/vendor/drupal-pattern-lab/core/src/PatternLab/PatternData/Helpers/LineageHelper.php on line 220
PHP Warning:  array_unique() expects parameter 1 to be array, null given in /Users/tanc/Sites/agile_profile/l.jmp/gitroot/web/themes/custom/jmp_theme/pattern-lab/vendor/drupal-pattern-lab/core/src/PatternLab/PatternData/Helpers/LineageHelper.php on line 220

Notice: Undefined offset: 3 in /Users/tanc/Sites/agile_profile/l.jmp/gitroot/web/themes/custom/jmp_theme/pattern-lab/vendor/drupal-pattern-lab/core/src/PatternLab/PatternData/Helpers/LineageHelper.php on line 220

@sghoweri
Copy link

sghoweri commented Jun 7, 2017 via email

@tanc
Copy link

tanc commented Jun 7, 2017

Chasing my tail a bit here but I think I had removed the regex from config in those errors above. Now with what I think is the correct config:

lineageMatch: |-
  {%([ ]+)?(?:include|extends|embed)(
    |\\()["\\']([\\/.@A-Za-z0-9-_]+)["\\']([\\s\\S+]*?)%}

I get a lot of errors:

Warning: preg_match_all(): Unknown modifier '.' in /Users/tanc/Sites/agile_profile/l.jmp/gitroot/web/themes/custom/jmp_theme/pattern-lab/vendor/drupal-pattern-lab/core/src/PatternLab/PatternData/Helpers/LineageHelper.php on line 216

@tanc
Copy link

tanc commented Jun 7, 2017

Confirming the goal is to get data inheritance in pattern lab working as they would with shorthand syntax.

The data transform plugin only works with shorthand syntax (vanilla code).

@tanc
Copy link

tanc commented Aug 12, 2017

Is there anything I can do to help move this along?

@EvanLovely
Copy link
Member

@tanc We've got this fixed over in our fork of this: drupal-pattern-lab#1

@tanc
Copy link

tanc commented Aug 14, 2017

Great! I'll get to testing it this week

@tanc
Copy link

tanc commented Aug 15, 2017

@EvanLovely I've been testing this morning but can't get inheritance to work with your fork. I've created a new issue on your forked repo: drupal-pattern-lab#4

@tanc
Copy link

tanc commented Feb 13, 2018

I've returned to this now that the fork has been merged. I'm still seeing the same problems though:

Warning: preg_match_all(): Unknown modifier '.' in /Users/tanc/Sites/l.responsive_menu/gitroot/web/themes/custom/site_theme/pattern-lab/vendor/pattern-lab/core/src/PatternLab/PatternData/Helpers/LineageHelper.php on line 218

Any clues how to fix?

@tanc
Copy link

tanc commented Feb 13, 2018

Ahah, finally I have it working with the lineage helper line in config.yml like this:

lineageMatch: '{%([ ]+)?(?:include|extends|embed)( |\()["\']([\/.@A-Za-z0-9-_]+)["\']([\s\S+]*?)%}'

which after running npm start then gets correctly converted to:

lineageMatch: >-
  {%([ ]+)?(?:include|extends|embed)(
  |\()["\']([\/.@A-Za-z0-9-_]+)["\']([\s\S+]*?)%}

If I pasted in the converted lineage match line it got double escaped and broke.

@tanc
Copy link

tanc commented Feb 13, 2018

Have now tested more thoroughly with aleksip/plugin-data-transform and can confirm lineages are working nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants