fix twig_first/twig_last error when twig_slice returns boolean

twig_slice can return a boolean when slicing a string outside of its bounds.
this would cause a knock-on error in first/lasts usage of current as that
would be expecting an array.

this commit introduces a new function twig_current which handles these cases,
and returns null when bounds are exceeded.