-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Middleware lets script placeholders slip through undeleted in certain cases #277
Comments
Here's a simple testcase that reproduces this: def test_dependencies_with_no_components(self):
template = Template(
"""
{% load component_tags %}
{% component_dependencies %}
"""
)
rendered = template.render(Context())
# Assertions to ensure placeholders are properly replaced or removed
self.assertNotIn(
'<script name="JS_PLACEHOLDER"></script>', rendered, "JS placeholder should be removed"
)
self.assertNotIn(
'<link name="CSS_PLACEHOLDER">', rendered, "CSS placeholder should be removed or replaced"
) |
I had a brief look into this and the JS/CSS dependencies rendering. The middleware approach seems to be kinda-sorta working (if I stream the response, or I use different content-type than For that, we need to be aware of the rendering execution - when it starts and when it stops. We also need to access the rendered content, so we can do string replacement like we do in the middleware. Some ideas to achieve that:
|
In the course of PR #271 it came to light that one user was observing script placeholder tags in their generated html, despite the middleware being enabled.
(For the uninitiated, these placeholders are added by the
component_js_dependencies
tag when render_dependencies=True. Later, the middleware finds-and-replaces them with script tags linking to the appropriate js scripts.)So far, we haven't been able to reproduce this behavior, but the conversation in the PR includes an interesting hint:
We most likely have a bug on our hands. The fact that we can't repro it probably indicates a blind spot in our tests. We're investigating the issue.
If you're noticing similar behavior in your projects, please let us know. Real-world code bases are much better for helping us understand subtle issues like this.
The text was updated successfully, but these errors were encountered: