From c55d634fd68f6b5bbe070fbc195e0fef0e60f3eb Mon Sep 17 00:00:00 2001 From: Steven McCoy Date: Sun, 14 Apr 2019 07:35:31 -0400 Subject: [PATCH] Returns early if attributes are falsy This makes it easier to pass in variables that may be null or undefined --- add_attributes.function.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/add_attributes.function.php b/add_attributes.function.php index 9e95113..79fc1ae 100644 --- a/add_attributes.function.php +++ b/add_attributes.function.php @@ -7,6 +7,10 @@ use Drupal\Core\Template\Attribute; $function = new Twig_SimpleFunction('add_attributes', function ($context, $additional_attributes = []) { + if (!$additional_attributes) { + return; + } + if (class_exists('Drupal')) { $attributes = new Attribute();