Skip to content

Feature/1092 twig namespaces #1093

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

Merged
merged 2 commits into from
Nov 12, 2019

Conversation

zhawkins
Copy link
Contributor

@zhawkins zhawkins commented Nov 7, 2019

Currently we're finding the twig partial folder by splitting the path based on the namespace ID (i.e. Atoms). This works well if we're using the atomic naming convention but not so much for others. At work we use Drupal theme names as our twig namespaces so this breaks in new and wondrous ways for us.

This PR updates how the fullFolderPath is generated. Instead of splitting on namespace ID we're splitting on the resolved namespace path. This allows us to leave the ID out of it while still figuring our the correct partial folder.

Before:

tempPartial = '/Users/foo/Sites/pattern-lab/source/_patterns/05-test/00-test.twig'

selectedNamespace[0].id = 'some_thing'

const fullFolderPath = `${
  tempPartial.split(selectedNamespace[0].id)[0]
}${selectedNamespace[0].id}`;

fullFolderPath = '/Users/foo/Sites/pattern-lab/source/_patterns/05-test/00-test.twigsome_thing'

After:

tempPartial = '/Users/foo/Sites/pattern-lab/source/_patterns/05-test/00-test.twig'

selectedNamespace[0].paths[index] = 'source/_patterns/05-test'

const fullFolderPath = `${
  tempPartial.split(selectedNamespace[0].paths[index])[0]
}${selectedNamespace[0].paths[index]}`;

fullFolderPath = '/Users/foo/Sites/pattern-lab/source/_patterns/05-test'

Closes #1092

@zhawkins
Copy link
Contributor Author

zhawkins commented Nov 7, 2019

@sghoweri , I believe you worked on this code at some point so maybe you can help me figure out if there's a better way to do this. 👋

Copy link

@mariohernandez mariohernandez left a comment

Choose a reason for hiding this comment

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

Tested patch locally and confirmed issues with warnings during npm run build about not finding the corresponding patterns, have been fixed.

@bmuenzenmeyer bmuenzenmeyer merged commit 59de7ac into pattern-lab:dev Nov 12, 2019
@bmuenzenmeyer
Copy link
Member

thank you @zhawkins and @mariohernandez for the fix and verification - it goes a long way toward helping make PL the cross-platform / cross-language thing we rely on

antonia-rose pushed a commit to quelltexterin/nemo-uikit-workshop that referenced this pull request Apr 12, 2023
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.

Engine Twig PHP isn't very flexible with namespaces
3 participants