-
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
Support passing a root #11
Conversation
ok so finally figured out my brainfart while trying to build it ( had literally setup an ubuntu virtualbox after git bash accepted rm but not rollup, and i failed to check if rollup was node... anyway) and have placed the dist file in my project. After fluffing around figuring out how the root location worked, its essentially the exact same problem. im loading a template with
and while it finds the initial twig file, where you have joined the root and filepath, it fails to find the template import, which is trying to extend a file from the root directory as named. Unable to find template file templates\pages\bin\lookup.html.twig. Error: ENOENT: no such file or directory, stat 'templates\pages\bin\lookup.html.twig' because the lookup.html.twig is in |
Does symfony have its own twig-loader that special cases the templates folder? |
Very likely, they made twig. |
From the docs, twig templates are compiled to php so extends will be mapped as it does it. |
are you wrapping a js library that loads them ? |
Yeah I dont think it can be done, twig in php has a registered base of where templates are loaded from, and twigjs treats the first one loaded as the reference. While this is fine for using twig in a js project, it isnt compatable with the php implementation. shame. In order to get this I'd have to modify the twigjs library to have an abilioty to process everything from a decalred root. And I just dont have the time it'll take for me to figure out how to do that. Thanks for the attempt tho :) |
that being said, if i could gather the templates into an array and then just reference them by name.... tho then i'd have to ensure all paths had their own names, and for instance in the project I'm looking at now its got like 15 compoenet paths where the page ends up being called index.html.twig. So sure theres a workaround in there somewhere. maybe even being able to pass the templates in as an array with the reference names being the extends names, and then they could all be treated as if in the same place. |
Namespaces is how I deal with this in Drupal |
Thanks, looking into this now. |
is the namespace support in the testing library so i can map my namespaces or so i can reference one to use from twig.yaml ? |
the third argument to |
Yeah sorry this is why I'd asked. in your example you dont make use of the namespace so I'm not sure what I'm setting up there. you define my_namespace and then dont refer to it. You dont provide the content of the example accordion.js in the brief intro docs and the files in the tests folder also define but then dont appear to use namespaces. I'm expecting
to work, have tried with and without the @ |
So here's an example {# some-file.twig #}
<div>
{% include "@my_namespace/foo.twig" %}
</div> render(
'/path/to/some-file.twig',
{},
{
my_namespace: '/path/to/where/the/namespace/root/is'
}
) i.e you use the fixed path in the test, but in the templates it renders, it can find the includes by their namespace |
ohhhhhhh. right. context. Choice. thanks, please add that to your docs too, I've now got an undefined document object, but have yet to suspect its template related. Also there doesnt appear to be any reference to this library on the more examples pages, fyi. |
Going to close this, as it seems namespaces are the better option. |
Fixes #5