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 for Pattern Lab Pattern Viewer Not Displaying Namespaced Lineage Twig Paths #105

Closed
wants to merge 2 commits into from
Closed

Fix for Pattern Lab Pattern Viewer Not Displaying Namespaced Lineage Twig Paths #105

wants to merge 2 commits into from

Conversation

sghoweri
Copy link
Contributor

1st pass at updating how PL template lineage matches are handled, even if the regex for a lineage matches up.

Addresses an annoying issue that's been going on for quite a long time now where the PL pattern viewer can't / won't correctly display the matched lineages of Twig partials when the @ namespace full path is used (vs the shorthand PL path syntax).

For example, given the following lineageMatch config in my config.yml file (separate PR?):
lineageMatch: '{%([ ]+)?(?:include|extends|embed)( |\()["\']([\/.@A-Za-z0-9-_]+)["\']([ A-Za-z0-9-&\}_\n\{":\',\/. \[\]]+)%}'
PL correctly picks up the pattern lineage in my code, even if I'm using a longhand / Twig namespaced path in my code (which is currently required for PL / Drupal to speak the same language, path-wise):

{% include "@atoms/typography/headings/h1.twig" with {
heading: {
text: "My Awesome Heading"
}
} %}

In my testing, I can confirm that this include correctly gets picked up when the $foundLineages array gets defined, however it seems to fail afterward due to the lineage path / string not being formatted in the compact shorthand format PL expects.

Basically, this PR works around this by doing some clunky PHP regex / string cleanup on the matched lineage path so it ends up matching what PL expects (feedback welcomed and appreciated)!

…n if the regex for a lineage matches up.

Addresses an ongoing issue where the pattern viewer doesn’t correctly display matched lineages of Twig partials when the @ namespace full path is used (vs the shorthand PL path syntax).
…es where the matched pattern might be hidden (and subsequently not match properly)
@sghoweri
Copy link
Contributor Author

sghoweri commented Nov 5, 2017

Also closing this one out - we fixed this issue in #129

@sghoweri sghoweri closed this Nov 5, 2017
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

Successfully merging this pull request may close these issues.

2 participants