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

Fixed #6271, #18260.
Merge pull request #751 from bmispelon/ticket-6271