Reputation: 150178
In Template Toolkit there's the RETURN
directive which can be used to stop processing the current template and return to the template from which it was called. How can I do this in Mojolicious?
Upvotes: 3
Views: 131
Reputation: 157
Based on the documentation saying templates work just like Perl subs (actually they get compiled to a Perl sub internally) I did some experiments. It appears that a simple
% return;
returns from a template discarding all its output. And
% return $_M;
returns from a template and keeps all its output generated before the return statement.
Please note that these are unofficial hacks. To find more possibilities to interact with Mojolicious internals you can try
% use Data::Dumper; return Dumper $self;
in your template and see the output and discover pretty much everything that is happening in the compiled templates.
Upvotes: 1