[Catalyst] How to get uri_for something with a fragment?

Andrew Rodland andrew at cleverdomain.org
Sun Mar 6 11:28:26 GMT 2011


On Sunday, March 06, 2011 05:07:25 AM John M. Dlugosz wrote:
>   How do I call uri_for_action and pass it the '#id' part?  It's not an arg
> and it's not part of the query string.  This is called the fragment
> identifier in the final URL.

uri_for returns a URI object, so you can always

my $uri = $c->uri_for_action(...);
$uri->fragment('id');
# Use $uri

Or, since you know that what it generates *doesn't* have a fragment you could 
always just $c->uri_for_action(...) . '#id' which will be perfectly valid 
(although no longer a URI object).

Andrew



More information about the Catalyst mailing list