Revert r37299. It's causing some extremely strange behavior that I can't pin down. Try copying the text =={{[[Navbox]]}}== into a page, where [[Template:Navbox]] is copied from enwiki. An exhibit is up at <en.wikipedia.org/wiki/User:Simetrical/Tl_test> until this fix goes live. This was reported at <http://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)#Problem_with_.7B.7Btl.7D.7D_in_section_headers> by CapitalR; thanks to RockMFR for tracking down the revision that was causing it.
As a general rule, it would be a good idea to first split the functions off into their own file without changing them, and then refactor them in a separate commit. Otherwise it's very hard to follow what's actually being changed. (git actually tracks changes to functions when they're moved across files, incidentally, which is quite awesome.)