Mojolicious::Plugin::UrlWith - Preserve parts of the url
0.0502
This helper provides the same method as "url_for" in Mojolicious::Controller with the difference that it keeps the query string.
package MyApp; sub startup { my $self = shift; $self->plugin('Mojolicious::Plugin::UrlWith' => { parse_fragment => 1, current_page_class => 'current-page', }); # ... }
Will remove the '#fragment' part from the first arugment to "url_with", and use it use it for "fragment" in Mojo::URL.
$self->current_page_class($classname); $classname = $self->current_page_class;
Will add the $classname to the link in "link_with" if the path part of the link match the currently requested path. You need to set this attribute when registering the plugin, since the default value is empty string, cancelling the behavior.
$classname
This attribute is EXPERIMENTAL and may be removed/changed without warning.
The examples below has this current request url: http://somedomain.com/search?page=1.
http://somedomain.com/search?page=1
Will result in http://somedomain.com/search?page=1&name=bob.
http://somedomain.com/search?page=1&name=bob
Will result in http://somedomain.com/search.
http://somedomain.com/search
Will result in http://somedomain.com/some/named/route?page=1&age=42.
http://somedomain.com/some/named/route?page=1&age=42
Will result in http://somedomain.com/path?page=1&random=24.
http://somedomain.com/path?page=1&random=24
Will result in http://somedomain.com/path?c=313.
http://somedomain.com/path?c=313
Summary: A hash-ref will be merged with existing query params, while an array-ref will create a new set of query params.
Same as "link_to" in Mojolicious::Plugin::TagHelpers, but use "url_with" instead of "url_to" in Mojolicious::Controller to construct the hyper reference.
Will register the methods under "HELPERS".
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.
Jan Henning Thorsen
To install Mojolicious::Plugin::UrlWith, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::UrlWith
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::UrlWith
For more information on module installation, please visit the detailed CPAN module installation guide.