DrupalX

Extension
Framework

Merge operator

By default, it's relatively complicated to add new elements to an existing array (at least when you consider, that this can be a quite frequently used operation):

set colors=["red","yellow"];
if category=="business";
  set colors=colors | merge(['blue']);
endif;

DrupalX is therefore adding a merge operator "&" which makes this a bit more readable:

set colors=["red","yellow"];
if category=="business";
  set colors=colors & "blue";
endif;

As you can see, the merge operator (in contrast to Twig's built-in "merge" filter) also allows adding scalar values directly. It's not necessary to wrap the value into sqaure brackets to create a single-item array.