-
Notifications
You must be signed in to change notification settings - Fork 2
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
Render a template with includes #5
Comments
Can you share an example of your template and folder structure? I should be able to use that to write a test-case. |
Same issues here. const { container} = await render( Base templates are common, and with a large enough project, feature templates naturally can end up in their own folders. The render doesnt provide a facility to indicate what the root template folder is, so if i have base.html.twig in the templates folder, and custom.html.twig in a feature folder off templates, with the test library you cant have {% extends 'base.html.twig' %} in the custom template, whilst this is fine when running the template in symfony for instance. I was able to workaround to get onto other errors by making the path relative in the extends, such as '../../base.html.twig' but I doubt this would work for symfony as its expecting things to be in the template folder. (plus in symfony I'm rendering 'pages/bin/index' which refers to '/templates/pages/bin/index.html.twig') a param to specify the base dir perhaps. |
I'm not too familiar with twig in symfony, but happy to take suggestions on how to solve this. Under the hood it's using twig.js so we're reliant on what it supports in terms of include paths, namespaces being the option we already support - but there may be more |
When twig is used in symphony, the code is essentially running from the project root. When its getting templates, it considers everything to be based in a templates directory. As it stands, when the testing lib loads a template, any references its making with extends are treating the file location to be the root, so while ....\base.html.twig works from the test, that will break the app. Needs to be relative to template folder, not the location of any particular template. |
Ok post messed that up. .. \ .. \ base.html.twig. this will break the original app but is accepted in the test. |
Give #11 a try |
Ooooh. Will be sure to give it a bash in a bit. Thanks for progressing things along. |
Ok so the source and the index.js in dist are vastly different, how do i give #11 a try exactly ? |
running |
Ah right |
@rbnzdave How can I solve that issue? 🙏 |
I'd like to test a twig file that extends another twig file in my templates directory. Jest throws an error because it can't find the base template. Is there a way to configure the default namespace with main or "." without setting up a custom Twig namespace?
The text was updated successfully, but these errors were encountered: