Based on the documentation, they say that templates work the same way as Perl submarines (in fact, they are compiled into Perl sub internally). I did some experiments. It seems that simple
% return;
returns a template discarding all its output. AND
% return $_M;
returns from the template and saves all its output data before the return statement.
, . Mojolicious internals,
% use Data::Dumper; return Dumper $self;
, .