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

Fix Pattern Lab Twig Lineages When Using D8-friendly Twig Paths (Part 1 of 2) #1

Merged
merged 3 commits into from
May 9, 2017

Conversation

sghoweri
Copy link
Collaborator

@sghoweri sghoweri commented May 1, 2017

First half of the fix required in order to get pattern lineages working in Pattern Lab again when using Twig templates and/or use virtually any character in your template that the original regex can't account for.

Note: this shouldn't appear to change any current lineage behavior just yet if just testing this one part. Once the other LineageHelper.php fix is in place this should be fully up and running.

Adds and expands Pattern Lab lineage support (on the regex side) when using Twig templates:

  1. That call include, embed OR extend now (previously only worked with includes)
  2. That include any special characters in the path including the @ sign, dots, etc. (previously only worked with a-z, A-Z, numbers, dashes and hyphens).
  3. That include the .twig file extension in the path (previously failed)
  4. That include one or multiple parameters via the Twig with syntax including commas (previously failed)
  5. That include parameters with values using special characters like parentheses, hashes, percent signs, greater than / less than signs, etc. (previously failed on all parameters)
  6. That still continue to use the shorthand path syntax (still works)
  7. That span across one or multiple lines, including line breaks (previously failed)

Testing notes:

  1. PL still compiles properly without any errors if using the updated regex logic but still using the originl unpatched LineageHelper.php file.

  2. Same is also true (no errors) if using the updated LineageHelper.php logic but the _config.yml is using the old Twig regex

  3. Using the updated regex + updated LineageHelper.php logic also compiles successfully without any errors, however it also appears to fully fix the broken Pattern Lab lineage functionality that's been broken for quite some time, at least based on out in the wild

  4. Furthermore, tested requiring this json-friendly version in via composer which properly adds the yaml-friendly / converted version to config.yml:

ex. config.yml should look something like this when updated.

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

@sghoweri sghoweri requested review from EvanLovely and aleksip May 1, 2017 18:51
@EvanLovely EvanLovely added this to the v2.2 milestone May 9, 2017
Copy link

@EvanLovely EvanLovely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me; especially since it wasn't working before anyway :P What's part 2? Could you open up an issue as a placeholder please? Thanks for getting this in!

@EvanLovely EvanLovely merged commit a2657fa into dev May 9, 2017
@EvanLovely EvanLovely deleted the feature/fix-and-extend-twig-regex branch May 9, 2017 21:07
@sghoweri
Copy link
Collaborator Author

sghoweri commented May 9, 2017

@EvanLovely - can definitely throw in a placeholder issue into our fork of PL Core

I THINK Part 2 is almost ready for a PR -- this week's just been crazy busy so I haven't gotten to it yet (BUT SOON!) =P

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

Successfully merging this pull request may close these issues.

3 participants