fixed support for templates with auto-edit of main file