Using filter strtolower in custom Twig Extension return no result I created a module to extend Twig Extension for filter functions. However the usage of strtolower in custom module end up with no result. Below are the sampel code of my custom module.

  public static function removeSpaces($string) {
    $string = str_replace(' ', '-', $string);
    $string = strtolower($string);

    return $string;
  }


Filtering {{ title|removeSpaces }} in template end up with empty.
You have to render the array and then use the custom twig filter:

{{ title|render|removeSpaces }}