User blog comment:Kirkburn/Syntax highlighting - helping you read and write code/@comment-4902411-20150309184851/@comment-126761-20150309193111

It's based on the number of  brackets, essentially. Two brackets get 'template' colouring, three brackets get 'parameter' colouring. Colours cannot mix, so the 'deepest' code gets coloured first.

I could try describing it with more detail, but it's easier just to see it in action on one of the test wikias :)