On Mon, May 29, 2017 at 9:18 AM, Alex Povolotsky <[email protected]> wrote:

> Exactly what I want... with just one (deadly) problem. It yields
> double-encoded UTF8 :(


My original solution was overcomplicated for some reason.  Try:

*$ cat inline *
#!/usr/bin/env perl
use Mojolicious::Lite;

helper template => sub { 'Σὲ γνωρίζω ἀπὸ τὴν κόψη <%= $id %>' };
helper inline => sub {
  my $c = shift;
  return $c->render_to_string(inline => shift, handler => "ep", format =>
"html", @_);
};

get '/' => sub {
  my $c = shift;
  # Where $c->template if your call to a database to retrieve a template
  $c->stash(id => 123, tmpl => $c->template)->render(inline => '<%= 1+1 %>
<%= inline $tmpl %>');
};

app->start;

*$ perl inline get /*
[Mon May 29 22:50:03 2017] [debug] GET "/"
[Mon May 29 22:50:03 2017] [debug] Routing to a callback
[Mon May 29 22:50:03 2017] [debug] Rendering inline template
"7acb215c9281b69e67988118eb0ac8c3"
[Mon May 29 22:50:03 2017] [debug] Rendering inline template
"81148fb72bfd5a36d2e792c632663ec6"
[Mon May 29 22:50:03 2017] [debug] 200 OK (0.001816s, 550.661/s)
*2 Σὲ γνωρίζω ἀπὸ τὴν κόψη 123*

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to