django-pipeline icon indicating copy to clipboard operation
django-pipeline copied to clipboard

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

Open mfvictor opened this issue 2 years ago • 1 comments

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.

mfvictor avatar Sep 12 '22 14:09 mfvictor

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

zakx avatar Sep 13 '23 21:09 zakx