Skip to content

fix(engine_twig_php): Twig incremental rebuilds #1036

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

Conversation

zhawkins
Copy link
Contributor

Fixes issue where edits to twig files included in parent do not appear
until the parent file is updated.

Closes issue #1015

Summary of changes:

  • Updates regex patterns to match multi-line includes, extends and embeds. (See examples on line 123)
  • Updates regex patterns to match both single and double quotes.
  • Adds findPartials support which should find any partials that contain include, embeds or extends.
  • Adds findPartial support which should take the include/embed/extend and use any provided namespaces to resolve a partial file. That partial file is used to return a pattern key.

Fixes issue where edits to twig files included in parent do not appear
until the parent file is updated.

Closes issue pattern-lab#1015
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.

Glad to see this working.

@sghoweri
Copy link
Contributor

Hmmm. I feel like I’ve seen that Twig regex pattern before! 😊

Fixes issue where programmatically created twig includes would throw
a warning at compile time.

Closes issue pattern-lab#1015
@bmuenzenmeyer
Copy link
Member

I dont have the bandwidth to check out these Twig PRs, can someone else please review?

@sghoweri
Copy link
Contributor

I dont have the bandwidth to check out these Twig PRs, can someone else please review?

🙋‍♂@bmuenzenmeyer starting to take a look at this!

Copy link
Contributor

@sghoweri sghoweri left a comment

Choose a reason for hiding this comment

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

This is almost good to go @zhawkins!

The main issue I ran into while testing this out has to do with resolving Twig namespaced-paths when the recursive option is enabled.

Basically Twig includes like @molecules/teaser-card.twig should work the exact same way as @molecules/teaser-card/teaser-card.twig but with the added benefit of being able to move around templates internally without breaking a bunch of paths in the process.

I'm taking a look to see if I can adjust your findPartial logic here to take this into account so a ton of warnings aren't thrown!

@sghoweri
Copy link
Contributor

Fixed it! Now the shorter hand Twig namespace syntax works too (plus no missing templates / warnings when compiling).

Pushing this update up shorty so we can get this merged. 🙂

# Conflicts:
#	packages/engine-twig-php/lib/engine_twig_php.js
@zhawkins zhawkins requested a review from raphaelokon as a code owner October 13, 2019 21:00
Copy link
Contributor

@sghoweri sghoweri left a comment

Choose a reason for hiding this comment

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

Fixed it! Now the shorter hand Twig namespace syntax works too (plus no missing templates / warnings when compiling).

Pushing this update up shorty so we can get this merged. 🙂

@zhawkins for reference, these were the couple of small things I had to change to get some additional Twig use cases accounted for.

Basically I updated your PR to look through all Twig namespaces after the Twig renderer recursively adds nested folders (vs the namespaces before the Twig renderer boots up) + added support for matching up partial Twig include paths (@molecules/teaser-card.twig), in addition to the paths you commented on that include nested folders. Thanks again for this! 👍

@sghoweri sghoweri merged commit 281458b into pattern-lab:dev Oct 13, 2019
@zhawkins
Copy link
Contributor Author

Awesome! Thanks for doing that! 😎

antonia-rose pushed a commit to quelltexterin/nemo-uikit-workshop that referenced this pull request Apr 12, 2023
…incremental-rebuilds

fix(engine_twig_php): Twig incremental rebuilds
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.

4 participants