First question:
The way I embed CSS is below, is there a way to embed CSS without
using routes like get '/global.css'?
Second:
Is there a way to embed images, like base64 encoded, something like
below, and below is just an idea.
Thank you.
get '/global.css' => sub { my $self = shift; $self-
>render('global'); } => 'global';
@@ layouts/template.html.ep
<link href="index.cgi/global.css" rel="stylesheet" type="text/css"/>
@@ global.css.ep
@media all{.printlogo{position.........
In this is what I am tin
@@ /files/template/tel-logo.gif
R0lGODlhXQBrAOZ/
AMa6zPBWFWomg7qrxUwVdp5UltTL19fQ2xgIRPPy8/7/9/3/8aaUuVErd3Fe
k4uIkzQpUvjVqRQHOZaOpeLc4/n5+dDG1AkEF/7+/
uzp7KGhokpHUvOLJcfIyDgWafGvW9vV3X15
hQ0FIx8LU+ro8hIJK/n2+1FDc3MvhicSVv75/uXg5fr58DUNaC0nQOnl6vHu8/z8++rMb/
fuwUc4
XCALRl5Ua7+xyVEeD2NgaP78/yIVSDUUXf///CoMYGxldrWmv
No there is not, there always needs to be a matching route, static files are supposed to go into the public directory.
Actionless templates are possible though.
get '/foo.css' => 'foo';
@@ foo.css.ep
...
> Second:
> Is there a way to embed images, like base64 encoded, something like
> below, and below is just an idea.
If you really want to do this there is render_data.
use Mojo::ByteStream 'b';
get '/foo.png' => sub { shift->render_data(b(<<EOF)->b64_decode->to_string) };
...
EOF
--
Sebastian Riedel
http://labs.kraih.com
http://mojolicious.org
http://twitter.com/kraih
Thank you. This is very useful, but it would force me putting images
before shagadelic.
Do you suggest reading images from subroutines like:
$img = image();
#and then
get '/foo.png' => sub { shift->render_data(b($img)->b64_decode-
>to_string) };
or is there Mojolicious way to do it?
Think we'll add a base64 renderer to deal with embedded binary files, it would work like this.
# GET /foo.png
get '/foo' => 'foo';
@@ foo.png.b64
...
Due to the nature of Mojolicious::Lite and one-file possibility I was
thinking the functionality is there by default.
Including such a functionality is excellent, finally I can make a
single file server various domains with all what is required.
Louis