public string RenderMacro(string templateAlias, int contentId, params object[] properties) { var razorFileLocation = string.Format("{0}/{1}", SystemDirectories.MacroScripts.TrimEnd('/'), templateAlias.TrimStart('/')); Log.Instance.LogDebug("SendOrderEmail razorFileLocation: " + razorFileLocation); return(RazorLibraryExtensions.RenderMacro(razorFileLocation, contentId, properties)); }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (!(Page.Request.CurrentExecutionFilePath ?? string.Empty).Contains("editContent.aspx")) { return; } try { var documentId = HttpContext.Current.Request["id"]; int docId; int.TryParse(documentId, out docId); if (docId != 0) { _lblRenderRazorContent = new Literal { Text = RazorLibraryExtensions.RenderMacro(_razorFile, docId) }; if (ContentTemplateContainer != null) { ContentTemplateContainer.Controls.Add(_lblRenderRazorContent); } } } catch { _lblRenderRazorContent = new Literal { Text = "Error rendering data" }; if (ContentTemplateContainer != null) { ContentTemplateContainer.Controls.Add(_lblRenderRazorContent); } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (!(Page.Request.CurrentExecutionFilePath ?? string.Empty).Contains("editContent.aspx")) { return; } try { var documentId = HttpContext.Current.Request["id"]; int docId; int.TryParse(documentId, out docId); if (docId != 0) { var emailDoc = new Document(docId); var property = emailDoc.getProperty("emailtemplate"); if (property.Value == null) { // fallback for old installations property = emailDoc.getProperty("xslttemplate"); } if (property.Value != null) { var value = property.Value.ToString(); if (!string.IsNullOrEmpty(value)) { var fileLocation = string.Format("{0}/{1}", SystemDirectories.MacroScripts.TrimEnd('/'), value.TrimStart('/')); _lblRenderRazorContent = new Literal { Text = RazorLibraryExtensions.RenderMacro(fileLocation, docId) }; if (ContentTemplateContainer != null) { ContentTemplateContainer.Controls.Add(_lblRenderRazorContent); } } } else { _lblRenderRazorContent = new Literal { Text = "No template set or found, reload node?" }; if (ContentTemplateContainer != null) { ContentTemplateContainer.Controls.Add(_lblRenderRazorContent); } } } } catch { _lblRenderRazorContent = new Literal { Text = "Error rendering data" }; if (ContentTemplateContainer != null) { ContentTemplateContainer.Controls.Add(_lblRenderRazorContent); } } }
public string GetRenderedTemplate(int nodeId, string template) { return(RazorLibraryExtensions.RenderMacro(template, nodeId)); }