in reply to Rendering a file in any directory via Mojolicious::Lite

Consider the following, assuming that /tmp/mojoexample/testing.jpg is a valid image.

use Mojolicious::Lite -signatures; my $static = app->static; push @{$static->paths}, '/tmp/mojoexample/'; get '/' => sub($c){ $c->stash( name => 'testing' ); $c->stash( ext => '.jpg' ); } => 'index'; app->start; __DATA__ @@ index.html.ep <!DOCTYPE HTML> <html> <body> <img src="<%== $name.$ext %>" alt="it works!" /> </body> </html>

Mojolicious::Static -> paths.

Replies are listed 'Best First'.
Re^2: Rendering a file in any directory via Mojolicious::Lite
by clueless newbie (Curate) on Feb 07, 2024 at 15:08 UTC

    Many thanks! I owe you a beer!

      Anytime (beers or perl help) :D