protected override string Render() { dynamic xt = new XTemplate(Layout.IntranetControllerView); xt.UserName = this.Context.Engine.GetSession().User.Description; xt.TemplateName = this.Model.ViewMapper.TridionTemplate.Title; xt.TemplateTypeName = this.Model.ViewMapper.TridionTemplate is ComponentTemplate ? "component template" : "page template"; xt.ErrorMessage = this.Model.ViewMapper.Success ? "Oops, view not found!" : "Oops, invalid template name!"; xt.ControllerTypeName = this.Model.GetType().Name; xt.ViewFullTypeName = this.Model.ViewMapper.ViewFullTypeName; xt.ProjectNamespace = this.Model.ViewMapper.ProjectRootNamespace; xt.TemplateNameRegexPattern = this.Model.ViewMapper.TemplateNameRegexPattern; xt.Parse(!this.Model.ViewMapper.Success ? "root.invalidTemplateName" : "root.viewNotFound"); if (!string.IsNullOrEmpty(this.Model.ProjectDocumentationUrl)) { xt.ProjectDocumentationUrl = this.Model.ProjectDocumentationUrl; xt.Parse("root.projectDocumentation"); } return(xt.ToString()); }
protected override string Render() { // Instantiates a new XTemplate object with a parameter which is the // content of the embedded file XTemplateExample1View.html. The content // of this file is exposed by the resources file Layout through the property // Layout.XTemplateExample1View XTemplate xt = new XTemplate(Layout.XTemplateExample1View); // Assigns User.Description to variable {UserName}. // Assigns DateTime.Now.ToString("D") to variable {CurrentDate}. xt.Assign("UserName", this.Model.Session.User.Description); xt.Assign("CurrentDate", DateTime.Now.ToString("D")); // Parses the "administrator" block, if the current user is Administrator. if (this.Model.Session.User.IsSystemAdministrator) { // Assigns value "God" to variable {Role}. xt.Assign("Role", "Root"); // Block "administrator" is a child block of the "root" block. // The "root" block is the most outer block, which is a special // block. You don't have to explicitly specify the "root" block // in the markup. // The given block name for the .Parse() method has to be a fully // qualified block name. In this case "root.administrator". xt.Parse("root.administrator"); } /* ******************************* * Calling the .ToString() method without parameter returns the parsed "root" block * and is equal to the following two statements: * * xt.Parse("root"); * xt.ToString("root"); * * Or the following statement: * * xt.ToString("root"); * ******************************* */ return(xt.ToString()); }