fabpot/Twig — pull request #1500 by rodnaph (2014-09-08 16:02:57+00:00)
Title: 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.

null is returned over an empty string to allow detected of the bounds being exceeded.