How do I render two links with a pipeline as separator?
What you see as displayed HTML is escaped by Twig. Only safe markup is not escaped.

l() produces safe markup, but if you add something to it, the complete string becomes unsafe.

You can use an inline template to get around this problem.

if ($edit) {
  $action = [
    '#type' =&gt; 'inline_template',
    '#template' =&gt; '{{ edit }} | {{ action }}&lt;span class = 'loader'&gt;&lt;/span&gt;',
    '#context' =&gt; [
      'edit' =&gt; $edit,
      'action' =&gt; $action,
    ],
  ];
}