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

Macros support? #5

Closed
IHIutch opened this issue Nov 13, 2023 · 8 comments · Fixed by #6
Closed

Macros support? #5

IHIutch opened this issue Nov 13, 2023 · 8 comments · Fixed by #6

Comments

@IHIutch
Copy link

IHIutch commented Nov 13, 2023

Does this plugin support Twig macros? I'm trying to use one in pagination/templates/pagination-unbounded, but I'm getting the following error

An error occurred whilst rendering /project/home/ihiutch/workspace/stories/pagination/templates/pagination-unbounded.twig: TypeError: Cannot read properties of undefined (reading 'valueOf')

Codesandbox

**Also, excuse the other files, I found this plugin and am in the midst of migrating (If I can get macros to work!)

@larowlan
Copy link
Owner

Twig.js supports it so we should be able to support it.
I'll add a new test case and report back

@IHIutch
Copy link
Author

IHIutch commented Nov 13, 2023

I tried playing around with some simpler implementations and noticed that it seemed to work intermittently. But the error that came up (in browser) was always the same fs.statSync one

@larowlan
Copy link
Owner

Can you give #6 a try? Test in the PR seems to show it working, even with self references. Took me a while to get it going because I naffed up the macro syntax in the test twig files 🙃

@larowlan
Copy link
Owner

Happy to make a release with #6 if that's easier for testing, it doesn't make things any worse

@IHIutch
Copy link
Author

IHIutch commented Nov 13, 2023

Seems to be working, locally. Thank you!

Also working in the codesandbox

@larowlan
Copy link
Owner

Cutting a new tag

@larowlan
Copy link
Owner

https://github.com/larowlan/vite-plugin-twig-drupal/releases/tag/v1.0.2 should be on npm

@IHIutch
Copy link
Author

IHIutch commented Nov 14, 2023

Tyvm, this plugin has made working with Twig and Storybook so easy!

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 a pull request may close this issue.

2 participants