<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>

CC BY-SA 4.0
2024-12-06T18:26:13.687Z
2024-12-06T18:26:13.687Z
Mats Mikkel Rummelhoff
<p>Looks like the answer is <code>exit</code>:</p>
<pre><code>&lt;pre&gt;{{ myVariable) }}&lt;/pre&gt;
{% exit %}
</code></pre>

CC BY-SA 4.0
2024-12-05T13:18:44.093Z
2024-12-05T13:18:44.093Z
Jonathan Schofield
<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>

CC BY-SA 4.0
2024-12-05T14:53:04.223Z
The `return` tag is not native. You may have previously used the [Twig Perversion](https://plugins.craftcms.com/twig-perversion?craft5) plugin.
Lindsey D
<templating>
Craft 5.x: breaking out of a template with {% return %}
# 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:
{{ myVariable) }}
{% 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() Twig function is useful for this (and slightly more convenient than adding those  tags manually) e.g.
{{ dump(myVariable) }}
{% exit %}

Alternatively, there's the {% 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.
{% dd myVariable %}


---

### Answer by username_0 on 2024-12-05. Score: 0

Looks like the answer is exit:
{{ myVariable) }}
{% exit %}


---

