Fix an async problem by running compile inside the getTemplates callback