I am using the trim() function with _self to get the current page without the .twig extension. The code looks like this:
{% set active = _self|trim('.twig') %}
It works fine except when the filename of the page ends with a 'T'. It that case the 'T' in the file name before the '.' gets truncated. It seems that the 'T' in the file name is getting truncated because the extension also starts with 'T'.
In other words, if the file name of the template were mypage.twig or home.twig, the above snippet would be:
active = mypage
active = home
If the file name was test.twig or contact.twig, the snippet would be:
active = tes
active = contac
Perhaps this is a bug?
That is the same with the trim function in PHP.
The argument is a string of character_mask but not a string that you want to remove.
Most helpful comment
That is the same with the trim function in PHP.
The argument is a string of
character_maskbut not a string that you want to remove.