Answers.Body: <p>The <a href="https://craftcms.com/docs/5.x/reference/twig/functions.html#dump" rel="nofollow noreferrer"><code>dump()</code></a> Twig function is useful for this (and slightly more convenient than adding those <code>&lt;pre&gt;</code> tags manually) e.g.</p>
  <pre class="lang-none prettyprint-override"><code>{{ dump(myVariable) }}
  {% exit %}
  </code></pre>
  <p>Alternatively, there's the <a href="https://craftcms.com/docs/5.x/reference/twig/tags.html#dd" rel="nofollow noreferrer"><code>{% dd %}</code></a> (&quot;dump-and-die&quot;) tag, which will dump whatever variable you pass to it, and then terminate the request. Unlike the dump-and-exit approach it will not print the output up until its execution, though – only the thing being dumped.</p>
  <pre class="lang-none prettyprint-override"><code>{% dd myVariable %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-12-06T18:26:13.687Z
Answers.LastActivityDate: 2024-12-06T18:26:13.687Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.Body: <p>Looks like the answer is <code>exit</code>:</p>
  <pre><code>&lt;pre&gt;{{ myVariable) }}&lt;/pre&gt;
  {% exit %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-12-05T13:18:44.093Z
Answers.LastActivityDate: 2024-12-05T13:18:44.093Z
Answers.UserDisplayName: Jonathan Schofield
Body: <p>I’m building something in Craft 5 for the first time and it seems that breaking out of a template to print the output up to that point no longer works with the <code>return</code> statement.</p>
  <p>For example:</p>
  <pre><code>&lt;pre&gt;{{ myVariable) }}&lt;/pre&gt;
  {% return %}
  </code></pre>
  <p>…generates:</p>
  <pre><code>Unknown &quot;return&quot; tag
  </code></pre>
  <p>I cannot find any documentation on this. What are we supposed to do instead?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-12-05T14:53:04.223Z
Comments.Text: The `return` tag is not native. You may have previously used the [Twig Perversion](https://plugins.craftcms.com/twig-perversion?craft5) plugin.
Comments.UserDisplayName: Lindsey D
Tags: <templating>
Title: Craft 5.x: breaking out of a template with {% return %}
ThreadText: # Craft 5.x: breaking out of a template with {% return %}
  
  (Asked by: username_0 on 2024-12-05)
  
  I’m building something in Craft 5 for the first time and it seems that breaking out of a template to print the output up to that point no longer works with the `return` statement.
  
  For example:
  
  ```
  <pre>{{ myVariable) }}</pre>
  {% return %}
  
  ```
  
  …generates:
  
  ```
  Unknown "return" tag
  
  ```
  
  I cannot find any documentation on this. What are we supposed to do instead?
  
  **Tags:** templating
  
  > **Comments:**
  > **username_1**: The `return` tag is not native. You may have previously used the [Twig Perversion](https://plugins.craftcms.com/twig-perversion?craft5) plugin.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2024-12-06. Score: 1
  
  The [`dump()`](https://craftcms.com/docs/5.x/reference/twig/functions.html#dump) Twig function is useful for this (and slightly more convenient than adding those `<pre>` tags manually) e.g.
  
  ```none
  {{ dump(myVariable) }}
  {% exit %}
  
  ```
  
  Alternatively, there's the [`{% dd %}`](https://craftcms.com/docs/5.x/reference/twig/tags.html#dd) ("dump-and-die") tag, which will dump whatever variable you pass to it, and then terminate the request. Unlike the dump-and-exit approach it will not print the output up until its execution, though – only the thing being dumped.
  
  ```none
  {% dd myVariable %}
  
  ```
  
  
  ---
  
  ### Answer by username_0 on 2024-12-05. Score: 0
  
  Looks like the answer is `exit`:
  
  ```
  <pre>{{ myVariable) }}</pre>
  {% exit %}
  
  ```
  
  
  ---
  
  