Fixed #4622 (Patch: Improve formatting for custom templates)