Used token.split_contents() for tokenisation in template tags accepting variables.

Fixed #6271, #18260.