{{routeUrl(hashes)}}
Returns a url using route.url.
routeUrl( hashes... [,merge] )
Calls url with hashes
as its data
argument and an
optional merge
.
This can be used on its own to create <a>
href
s like:
<a href="{{ routeUrl(page='todos' id=todo.id) }}">details</a>
Or in conjunction with other helpers:
{{makeLink "details" routeUrl(page='todos', true)}}
{{routeUrl([merge], hashes...)}}
Passes the hashes to route.url
and returns the result.
<a href="{{routeUrl(page='todos' id=todo.id)}}">details</a>
Parameters
- merge
{Boolean}
:Pass
true
to create a url that mergeshashes
into the current can-route properties. - hashes
{Hash Expression}
:A hash expression like
page='edit' recipeId=id
.
Returns
{String}
:
Returns the result of calling route.url
.
Use
Use the routeUrl
helper like:
<a href='{{routeUrl page="recipe" id=5}}'>{{recipe.name}}</a>
This produces (with no pretty routing rules):
<a href='#!&page=recipe&id=5'>{{recipe.name}}</a>
This functionality could also be written as a call expression:
<a href='{{ routeUrl(page="recipe" id=5) }}'>{{recipe.name}}</a>
Using call expressions/parenthesis lets you pass the merge
option to route
. This
lets you write a url that only changes specified properties:
<a href='{{ routeUrl(id=5, true) }}'>{{recipe.name}}</a>
The following demo uses routeUrl
and {{#routeCurrent(hash)}} to
create links that update can-route’s page
attribute:
It also writes out the current url like:
{{ routeUrl(undefined,true) }}
This calls route.url({}, true)
which has the effect of writing out
the current url.