private TemplateViewData BuildTemplateViewData(Template template) { string siteDataDir = CuyahogaContext.CurrentSite.SiteDataDirectory; string absoluteBasePath = VirtualPathUtility.Combine(siteDataDir, template.BasePath) + "/"; string htmlContent = ViewUtil.RenderTemplateHtml(VirtualPathUtility.Combine(absoluteBasePath, template.TemplateControl)); string cssContent = GetCssContent(absoluteBasePath + "Css/" + template.Css); TemplateViewData templateViewData = new TemplateViewData(template, htmlContent, cssContent); templateViewData.PrepareTemplateDataForEmbedding(Url.Content(CuyahogaContext.CurrentSite.SiteDataDirectory)); return(templateViewData); }
public ActionResult View(int id) { Template template = this._templateService.GetTemplateById(id); string siteDataDir = CuyahogaContext.CurrentSite.SiteDataDirectory; string absoluteBasePath = VirtualPathUtility.Combine(siteDataDir, template.BasePath) + "/"; string htmlContent = ViewUtil.RenderTemplateHtml(VirtualPathUtility.Combine(absoluteBasePath, template.TemplateControl)); string cssContent = GetCssContent(absoluteBasePath + "Css/" + template.Css); TemplateViewData templateViewData = new TemplateViewData(template, htmlContent, cssContent); templateViewData.PrepareTemplateDataForEmbedding(Url.Content(CuyahogaContext.CurrentSite.SiteDataDirectory)); return(View("ViewTemplate", templateViewData)); }
public void RazorEngineService_CustomLocalizerHelper_OverrideInclude() { RunTestHelper(service => { // Tag must be closed! var model = new TemplateViewData() { Language = "lang", Model = new Person() { Forename = "forname", Surname = "surname" } }; var template = @"@Model.Forename @Include(""test"") @Localizer.Language"; service.Compile("@Model.Surname", "test", typeof(Person)); string result = service.RunCompile(template, Guid.NewGuid().ToString(), typeof(Person), model); Assert.AreEqual("forname surname lang", result); }, config => { config.BaseTemplateType = typeof(AddLanguageInfo_OverrideInclude <>); }); }
public void RazorEngineService_CustomLocalizerHelper_OverrideModelType() { RunTestHelper(service => { // Tag must be closed! var model = new TemplateViewData() { Language = "lang", Model = new Person() { Forename = "forname", Surname = "surname" } }; var template = @"@Model.Forename @Include(""test"") @Localizer.Language"; service.Compile("@Model.Surname", "test", typeof(Person)); string result = service.RunCompile(template, Guid.NewGuid().ToString(), typeof(Person), model); Assert.AreEqual("forname surname lang", result); }, config => { config.BaseTemplateType = typeof(AddLanguageInfo_OverrideModelType<>); }); }