/// <summary> /// Determines if the section with the specified name has been defined. /// </summary> /// <param name="name">The section name.</param> /// <returns></returns> public virtual bool IsSectionDefined(string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("The name of the section to render must be specified."); } return(_context.GetSectionDelegate(name) != null); }
/// <summary> /// Renders the section with the specified name. /// </summary> /// <param name="name">The name of the section.</param> /// <param name="isRequired">Flag to specify whether the section is required.</param> /// <returns>The template writer helper.</returns> public TemplateWriter RenderSection(string name, bool isRequired = true) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("The name of the section to render must be specified."); } var action = _context.GetSectionDelegate(name); if (action == null && isRequired) { throw new ArgumentException("No section has been defined with name '" + name + "'"); } if (action == null) { action = () => { } } ; return(new TemplateWriter(tw => action())); }