-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
addInlineJs Cache not working #1934
Comments
What is the full Twig? It makes a difference. |
modular.html.twig file:
modular template file:
Javascript works within the modular.html.twig file, but not in the modular template file. |
This is expected behavior. This is because modular subpages are processed along with their twig and then the resulting rendered html is stored as the content and cached. Once this the twig is not processed again so anything that is not output to html of that page is lost. However the solution is quite simple. Simply set This way the twig is run on this particular modular subpage every-time and yo won’t lose your JS. |
Ok, thanks for your help. It works... Of course, it would be better to leave the cache switched on. :) |
Is there another issue where this is tracked? |
ping / reopen-request |
There is really no way caching parts of the page output right now. My take on this is that I have plans to fix this issue, though it will require quite major architectural changes, so it will not be fixed until I have rewritten pages logic and made some additional fixes into elsewhere as well. I have some basis for this already implemented, though. The more detailed response is that I need to rewrite pages to the new |
I marked this for 1.7 even if it's likely that this will not be fully supported in that version. But the goal is to rewrite this part of the logic by 2.0. |
The underlying issue is that doctrine cache is only enabled for individuals pages but is not for a (modular) page as a whole. A very quick fix would be to enable cache for whole modular pages too. |
Enabling cache for whole modular pages would not resolve the issue. The issue is that when you call This is why we recommend |
It would be wonderful to add assets on a per modular basis. Hell you could even label that "component based" :P |
As 1.7 is out can we remark this for 2.0, as it would be nice to see this in an upcoming release? |
In an Twig Tempalate I have this code:
{% set script %}
alert('Test');
{% endset %}
{% do assets.addInlineJs(script,{ 'group':'bottom','priority':100 }) %}
{{ assets.js('bottom') }}
This code is successfully displayed in the html code the first time it is called:
But after a reload, the code section is no longer available. It looks like the inline cache is not working well.
Cache: [true] Setting: [auto] Driver: [file]
The text was updated successfully, but these errors were encountered: