2

While it's possible to pass an html element into a JS file declaration using 'with' as in:

{% js '/url/here' with { nonce: { nonce } } %}

this approach is not available for a JS inline code block for some reason:

{% js with { nonce: { nonce } } %} 
  code here 
{% endjs %} //doesn't work

Has anyone found a workaround for this?

1 Answer 1

1

You can use the {% script %} tag instead:

{% script with { nonce } %}
    code here
{% endscript %}
1
  • 1
    That works! Thanks so much. And yes, as you pointed out, 'with { nonce }' is all that's needed to render the variable in the tag. Commented Mar 5 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.