Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhthorsen/mojolicious-plugin-urlwith
as url_for(), but preserve query string
https://github.com/jhthorsen/mojolicious-plugin-urlwith
Last synced: 27 days ago
JSON representation
as url_for(), but preserve query string
- Host: GitHub
- URL: https://github.com/jhthorsen/mojolicious-plugin-urlwith
- Owner: jhthorsen
- Created: 2011-08-13T22:29:32.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-09-06T13:49:49.000Z (over 12 years ago)
- Last Synced: 2024-10-16T11:58:42.845Z (3 months ago)
- Language: Perl
- Homepage:
- Size: 113 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
Mojolicious::Plugin::UrlWith - Preserve parts of the urlVERSION
0.0502DESCRIPTION
This helper provides the same method as "url_for" in
Mojolicious::Controller with the difference that it keeps the query
string.SYNOPSIS
package MyApp;
sub startup {
my $self = shift;$self->plugin('Mojolicious::Plugin::UrlWith' => {
parse_fragment => 1,
current_page_class => 'current-page',
});# ...
}ATTRIBUTES
parse_fragment
Will remove the '#fragment' part from the first arugment to "url_with",
and use it use it for "fragment" in Mojo::URL.current_page_class
$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.This attribute is EXPERIMENTAL and may be removed/changed without
warning.HELPERS
url_with
The examples below has this current request url:
"http://somedomain.com/search?page=1".$controller->url_with({ name => 'bob' });
Will result in "http://somedomain.com/search?page=1&name=bob".$controller->url_with({ page => undef });
Will result in "http://somedomain.com/search".$controller->url_with('named', { age => 42 });
Will result in
"http://somedomain.com/some/named/route?page=1&age=42".$controller->url_with('/path', { random => 24 });
Will result in "http://somedomain.com/path?page=1&random=24".$controller->url_with('/path', [ c => 313 ]);
Will result in "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.link_with
Same as "link_to" in Mojolicious::Plugin::TagHelpers, but use "url_with"
instead of "url_to" in Mojolicious::Controller to construct the hyper
reference.METHODS
register
Will register the methods under "HELPERS".COPYRIGHT & LICENSE
This library is free software. You can redistribute it and/or modify it
under the same terms as Perl itself.AUTHOR
Jan Henning Thorsen