Cannot get role information in twig file I cannot seem to get the role of the current user in my twig template. I have tried the following:

{{ user.getRoles }}

{{ user.hasRole('content_administrator') }}


and neither return anything.

Notes:


I use a subtheme of radix.
I want to include stuff in the theme if the user has a certain role. Specifically, I have regular viewers and a content admin, and the content admin shall see extra things. I created a view called /revisionhistory which has a contextual link, and shows revisions. The theme should generate a link to /revisionhistory/{{node.id}} if the user has the administer_content role.
Displaying content if the user has a certain role:

{% if 'content_administrator' in user.getroles %}
  &lt;p&gt;Only displayed for the role Content Administrator&lt;/p&gt;
{% endif %}


More info: Restrict content to a user role in a template file