Clean up/reduce duplication in template-parser.
Clean up/reduce duplication in template-parser.

cybem/Selmer,lucacervello/Selmer,yogthos/Selmer,tdammers/Selmer,jstaffans/Selmer,seancorfield/Selmer,pbu88/Selmer