>From the Rendering Guide:

$c->render('foo/bar/baz', variant => 'phone');


What's a good way to recognize that the variant => 'phone' variable should
be set?

That is, I wouldn't have a route action like this:

get '/' => sub {
  my $c = shift;
  $c->render('foo/bar/baz', variant => 'phone');
};


Because then all user agents would get the phone variant, and then what's
the point of a variant?

Instead, one would need something like:

get '/' => sub {
  my $c = shift;

  $c->render('foo/bar/baz', variant => $c->is_mobile ? 'phone' : '');
};

I see that there is a plugin Mojolicious::Plugin::Mobi.  Is that the way to
do it?  Use its is_mobile() helper to determine whether or not to set the
variant to phone?

-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to