MakeSlugViewHelper

ViewHelper to render slug for requested route

Properties

Name: Type: Description:
for string Route name
with array Route parameters

Example

1
2
3
client_show:
   path:       api/client/{client}
   controller: Vendor\Demo\Controller\ClientApiController::show
{namespace route = LMS\Routes\ViewHelpers}

<a href="{route:makeSlug( for: 'client_show', with: {client: 2} )}">
   Show
</a>

// or initialize a JS constant
<script type="text/javascript">
   const showClientUrl = "{route:makeSlug( for: 'client_show', with: {client: 2} )}";
</script>

Output:

api/client/2
...

readResource(showClientUrl).then(function (client) {
   console.log(client);
});

...