Added mainTemplateData option so that custom data can be passed to main template