All other helpers

Following is the list of all other available view helpers.


app

Reference to the Application instance.

@if(app.nodeEnvironment === 'development')
Print some debug log
@endif

asset

The asset helper returns the path to a compiled frontend assets by doing a lookup inside the manifest.json file.

<script src="{{ asset('assets/app.js') }}"></script>
<link
rel="stylesheet"
type="text/css"
href="{{ asset('assets/app.css') }}"
>

assetsManager

The assetsManager helpers is a reference to the instance of AssetsManager class .

You will hardly rely on assets manager directly, as the asset helper and the @entryPointStyles and @entryPointScripts tags let you reference the assets inside your templates.


csrfToken

Returns the value of the CSRF token. The helper is only available when the @adonisjs/shield is installed and configured.

<input type="hidden" value="{{ csrfToken }}" name="_token">

csrfField

Returns the hidden input element for the CSRF token. The helper is only available when the @adonisjs/shield is installed and configured.

<form method="POST" action="posts">
{{ csrfField() }}
</form>

cspNonce

Returns the value for the nonce to be used with inline script tags. Make sure to read the CSP section in the web security guide.

<script nonce="{{ cspNonce }}">
</script>

auth

Reference to the ctx.auth instance. You can use it to display the specific portion of your markup conditionally.

@if(auth.isLoggedIn)
<p> Hello {{ auth.user.username }} </p>
@endif

bouncer

Reference to the ctx.bouncer instance. You can make use of the @can/@cannot tags to conditionally display markup inside your templates.