Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.
This repository was archived by the owner on May 13, 2026. It is now read-only.

Longhand includes break lineage #36

Open

Description

@jayfreestone

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.

Activity

  1. sghoweri commented on May 14, 2017

    @sghoweri

    @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!

  2. tanc commented on Jun 7, 2017

    @tanc

    @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?

  3. tanc commented on Jun 7, 2017

    @tanc

    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
    
  4. sghoweri commented on Jun 7, 2017

    @sghoweri
  5. tanc commented on Jun 7, 2017

    @tanc

    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
    
  6. tanc commented on Jun 7, 2017

    @tanc

    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).

  7. tanc commented on Aug 12, 2017

    @tanc

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

  8. EvanLovely commented on Aug 14, 2017

    @EvanLovely
    Contributor

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

  9. tanc commented on Aug 14, 2017

    @tanc

    Great! I'll get to testing it this week

  10. tanc commented on Aug 15, 2017

    @tanc

    @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

  11. tanc commented on Feb 13, 2018

    @tanc

    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?

  12. tanc commented on Feb 13, 2018

    @tanc

    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.

  13. tanc commented on Feb 13, 2018

    @tanc

    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

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