Search code examples
perlmojolicious

How to set up query arguments to `link_to` mojolicious helper?


I want to pass arguments for link generated by link_to helper:

%= link_to 'Change password' =>  'auth_remind', { login => $login }

but this does not work.

How to set up query arguments?


Solution

  • It is not documented yet, but in default welcome.html.ep we can found:

    %= link_to 'click here' => url_for
    

    So we can do next:

    %= link_to 'Change password' =>  url_for( 'auth_remind' )->query( login => $login )
    

    If we need to set up some arguments for route we may:

    %= link_to 'Change password' =>  url_for( 'auth_remind', { format => 'txt' } )->query( login => $login )