What is the replacement pattern in rewrite ouput for current user id? I have a custom content entity listed with Views.
I want to conditionally display some information depending on the fact that the row is related to the current user.
I tried {{ user:uid }} with no success.
Any idea?  

With help from @4k4, I could use 'Custom text' to add on each row of my Views output two 'buttons' (Edit, Delete) depending on the current user:  

{% if user_id_1=="[current-user:uid]"  %}
&lt;a href="/sel/service/{{ id }}/edit"&gt;&lt;img src="/sites/default/files/images/document-edit.gif" alt="" title="Modifier" width="11" height="13"&gt;&lt;/a&gt;
&lt;a href="/sel/service/{{ id }}/delete"&gt;&lt;img src="/sites/default/files/images/trash.gif" alt="" title="Supprimer" width="11" height="13"&gt;&lt;/a&gt;
{% endif %}



As you can see, there is also a button in the header (Add).
I'd like to have this button displayed only if the user is not anonymous.
I tried (in either Text area or Unfiltered text):  

{% if "0"=="[current-user:uid]"  %}
&lt;a href="/sel/service/add" class="form-submit hiddenforuser[current-user:uid]"&gt;Ajouter&lt;/a&gt;
{% endif %}


but it doesn't work:

Any idea why?
The twig variables in {{ }} are replacement patterns for fields. Globally available tokens are accessed by their usual square brackets syntax:

[current-user:uid]


Custom text field

This token works in a global text area, but not a custom text field, because this plugin Drupal\views\Plugin\views\field\Custom doesn't have global token replacement. You need to extend it and override renderAltered():

/src/Plugin/views/field/CustomToken.php

&lt;?php

namespace Drupal\mymodule\Plugin\views\field;

use Drupal\views\Plugin\views\field\Custom;

/**
 * A handler to provide a field extending custom by global token replacement.
 *
 * @ingroup views_field_handlers
 *
 * @ViewsField("custom")
 */
class CustomToken extends Custom {

  /**
   * {@inheritdoc}
   */
protected function renderAltered($alter, $tokens) {
    return $this-&gt;viewsTokenReplace($this-&gt;globalTokenReplace($alter['text']), $tokens);
  }
}


and tell the plugin manager about the new class:

mymodule.module:

function mymodule_views_plugins_field_alter(array &amp;$plugins) {
  $plugins['custom']['class'] = 'Drupal\mymodule\Plugin\views\field\CustomToken';
}


This applies the function globalTokenReplace() before the twig patterns are replaced.

Then you can use

{% if anotherfield_id == '[current-user:uid]' %} YES {% else %} NO {% endif %}


You have to enclose the token in single quotes so that you get a valid twig syntax after the global tokens are replaced.

Global text area

A global text area in header/footer is exactly the opposite, it supports global tokens but not Twig.

You could do the same as before and add Twig support in a custom plugin. But there is an easier solution. Install the module Twig input filter and go to "Text formats and editors" in Configuration and enable the Twig filter for the text format you use in the text area.