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

[Feature Request]: self.request to context in render_js #771

Open
mfvictor opened this issue Sep 12, 2022 · 1 comment
Open

[Feature Request]: self.request to context in render_js #771

mfvictor opened this issue Sep 12, 2022 · 1 comment

Comments

@mfvictor
Copy link

This is a feature request to add self.request to context in render_js on JavascriptNode.

This would be handy for cases where request context variables need to be rendered in the js template, for example, with django-csp you would be able to add a nonce in a custom template without having to extend JavascriptNode and writing a new tag to use it.

My suggestion is to add a key to extra_context which you can declare in settings with a boolean value that defaults to false. If true it adds self.request to context which will then be usable in the template.

If it's something anybody else is interested in, I could create a pull request for it.

@zakx
Copy link

zakx commented Sep 13, 2023

I have exact the same issue, trying to add a CSP nonce to pipeline script tags.

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

No branches or pull requests

2 participants