Answers.Body: <p>You can use the <a href="https://craftcms.com/docs/4.x/dev/tags.html#script" rel="nofollow noreferrer"><code>{% script %}</code></a> tag instead:</p>
  <pre><code>{% script with { nonce } %}
      code here
  {% endscript %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-03-05T19:17:00.033Z
Answers.Text: 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.
Answers.UserDisplayName: Jason McKinney
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-03-05T18:52:51.197Z
Answers.LastActivityDate: 2024-03-05T18:52:51.197Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>While it's possible to pass an html element into a JS file declaration using 'with' as in:</p>
  <pre><code>{% js '/url/here' with { nonce: { nonce } } %}
  </code></pre>
  <p>this approach is not available for a JS inline code block for some reason:</p>
  <pre><code>{% js with { nonce: { nonce } } %} 
    code here 
  {% endjs %} //doesn't work
  </code></pre>
  <p>Has anyone found a workaround for this?</p>
  
Tags: <tags><js>
Title: Adding a nonce tag to an inline code block
ThreadText: # Adding a nonce tag to an inline code block
  
  (Asked by: username_0 on 2024-03-05)
  
  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?
  
  **Tags:** tags, js
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-03-05. Score: 1 | Accepted answer
  
  You can use the [`{% script %}`](https://craftcms.com/docs/4.x/dev/tags.html#script) tag instead:
  
  ```
  {% script with { nonce } %}
      code here
  {% endscript %}
  
  ```
  
  > **Comments:**
  > **username_0**: 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.  
  
  ---
  
  