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>
|
|---|
| 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 | |
by marto (Cardinal) on Feb 07, 2024 at 16:34 UTC |