[events] Refactor the map generation template removing template code duplication