django-pipeline
django-pipeline copied to clipboard
[Feature Request]: self.request to context in render_js
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.
I have exact the same issue, trying to add a CSP nonce to pipeline script tags.