Making a menu in a scala template with some authorized links in them will look like this:
<ul>
<li><a href="@routes.Application.index()">Home</a></li>
@subjectNotPresent() {
<li><a href="@routes.Application.login()">Login</a></li>
}
@@restrict(handler, List(as("foo"))) {
<li><a href="@routes.Application.foo()">foo</a></li>
}
@subjectPresent() {
<li><a href="@routes.Application.logout()">Logout</a></li>
}
</ul>
I the link to Application.foo requires the role foo to be placed. However, I would like to change this statement @@restrict(handler, List(as("foo")))
to a more dynamic statement. I would like to ask if the user has access too application.foo instead of asking if a user has role foo.
This makes the menu less complex. An important benefit is that restrictions only have to be modified in the controllers, not the scala templates.
Is this possible?