{{#routeCurrent(hash)}}
Returns if the hash values match the can-route’s current properties.
routeCurrent( hashes... [,subsetMatch] )
Calls [can-route.current route.current] with hashes
and returns the result. This
can be used in conjunction with other helpers:
{{linkTo("Todos", routeCurrent(page='todos' id=todo.id))}}
Or on its own:
<a class="{{#routeCurrent(page='todos', true)}}active{{/routeCurrent}}">Todos</a>
Parameters
- hashes
{Hash Expression}
:A hash expression like
page='edit' recipeId=id
. - subsetMatch
{Boolean}
:If an optional
true
is passed,routeCurrent
will returntrue
if every value inhashes
matches the current route data, even if the route data has additional properties that are not matched.
Returns
{Boolean}
:
Returns the result of calling [can-route.current route.current].
{{#routeCurrent([subsetMatch,] hashes...)}}FN{{else}}INVERSE{{/routeCurrent}}
Renders FN
if the hashes
passed to [can-route.current route.current] returns true
.
Renders the INVERSE
if [can-route.current route.current] returns false
.
<a class="{{#routeCurrent(true, page='todos')}}active{{/routeCurrent}}">Todos</a>
Parameters
- subsetMatch
{Boolean}
:If an optional
true
is passed,routeCurrent
will returntrue
if every value inhashes
matches the current route data, even if the route data has additional properties that are not matched. - hashes
{Hash Expression}
:A hash expression like
page='edit' recipeId=id
. - FN
{sectionRenderer(context, helpers)}
:A subsection that will be rendered if the current route matches
hashes
. - INVERSE
{sectionRenderer(context, helpers)}
:An optional subsection that will be rendered if the current route does not match
hashes
.
Returns
{String}
:
The result of SUBEXPRESSION
or {{else}}
expression.
Use
Use the routeCurrent
helper like:
<li {{#routeCurrent(page="recipe" id=5)}}class='active'{{/routeCurrent}}>
<a href='{{routeUrl(page="recipe" id=5)}}'>{{recipe.name}}</a>
</li>
With default routes and a url like #!&page=recipe&id=5
, this produces:
<li class='active'>
<a href='#!&page=recipe&id=5'>{{recipe.name}}</a>
</li>
The following demo uses routeCurrent
and {{routeUrl(hashes)}} to
create links that update can-route’s page
attribute: