You are here

link.function.php in Unified Twig Extensions 1.0.x

File

example/_twig-components/functions/link.function.php
View source
<?php

if (!class_exists('Drupal')) {
  $function = new Twig_SimpleFunction('link', function ($title, $url, $attributes) {
    if (isset($attributes) && isset($attributes['class'])) {
      $classes = implode(' ', $attributes['class']);
      return '<a href="' . $url . '" class="' . $classes . '">' . $title . '</a>';
    }
    else {
      return '<a href="' . $url . '">' . $title . '</a>';
    }
  }, [
    'is_safe' => [
      'html',
    ],
  ]);
}