Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Class ContentAreaRenderer

The default implementation for rendering a ContentArea.

Inheritance
System.Object
ContentAreaRenderer
Namespace: EPiServer.Web.Mvc.Html
Assembly: EPiServer.Cms.AspNetCore.HtmlHelpers.dll
Version: 12.0.3
Syntax
public class ContentAreaRenderer : Object

Constructors

ContentAreaRenderer()

Initializes a new instance of the ContentAreaRenderer class.

Declaration
public ContentAreaRenderer()

ContentAreaRenderer(IContentRenderer, ITemplateResolver, IContentAreaItemAttributeAssembler, IContentRepository, IContentAreaLoader, IContextModeResolver, ContentAreaRenderingOptions, ModelExplorerFactory, IModelTemplateTagResolver)

Initializes a new instance of the ContentAreaRenderer class.

Declaration
public ContentAreaRenderer(IContentRenderer contentRenderer, ITemplateResolver templateResolver, IContentAreaItemAttributeAssembler attributeAssembler, IContentRepository contentRepository, IContentAreaLoader contentAreaLoader, IContextModeResolver contextModeResolver, ContentAreaRenderingOptions contentAreaRenderingOptions, ModelExplorerFactory modelExplorerFactory, IModelTemplateTagResolver modelTemplateTagResolver)
Parameters
Type Name Description
IContentRenderer contentRenderer
ITemplateResolver templateResolver
IContentAreaItemAttributeAssembler attributeAssembler
IContentRepository contentRepository
IContentAreaLoader contentAreaLoader
IContextModeResolver contextModeResolver
ContentAreaRenderingOptions contentAreaRenderingOptions
ModelExplorerFactory modelExplorerFactory
IModelTemplateTagResolver modelTemplateTagResolver

Properties

ContentRepository

The content repository

Declaration
protected IContentRepository ContentRepository { get; }
Property Value
Type Description
IContentRepository

Methods

AddNonEmptyCssClass(TagBuilder, String)

Add a css class to the Microsoft.AspNetCore.Mvc.Rendering.TagBuilder if it is not null or white space.

Declaration
protected virtual TagBuilder AddNonEmptyCssClass(TagBuilder tagBuilder, string cssClass)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.TagBuilder tagBuilder

The tag builder

System.String cssClass

The class to addd

Returns
Type Description
Microsoft.AspNetCore.Mvc.Rendering.TagBuilder

The given tag builder

BeforeRenderContentAreaItemStartTag(TagBuilder, ContentAreaItem)

Executed before the ContentFragment start tag has been written. Use this to modify the ContentFragments start tag.

Declaration
protected virtual void BeforeRenderContentAreaItemStartTag(TagBuilder tagBuilder, ContentAreaItem contentAreaItem)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.TagBuilder tagBuilder

The tag builder

ContentAreaItem contentAreaItem

The content area item

GetContentAreaHtmlTag(IHtmlHelper, ContentArea)

Gets the html tag for the container. Looks in the view data for the RenderSettings.CustomTag setting.

Declaration
protected virtual string GetContentAreaHtmlTag(IHtmlHelper htmlHelper, ContentArea contentArea)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The html helper

ContentArea contentArea

The content area

Returns
Type Description
System.String

The container html tag

GetContentAreaItemCssClass(IHtmlHelper, ContentAreaItem)

Gets the css class for the content area item. Looks in the view data for the RenderSettings.ChildrenCssClass setting.

Declaration
protected virtual string GetContentAreaItemCssClass(IHtmlHelper htmlHelper, ContentAreaItem contentAreaItem)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The html helper

ContentAreaItem contentAreaItem

The content area item

Returns
Type Description
System.String

The css class for the content area item

GetContentAreaItemHtmlTag(IHtmlHelper, ContentAreaItem)

Gets the html tag for the content area item. Looks in the view data for the RenderSettings.ChildrenCustomTag setting.

Declaration
protected virtual string GetContentAreaItemHtmlTag(IHtmlHelper htmlHelper, ContentAreaItem contentAreaItem)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The html helper

ContentAreaItem contentAreaItem

The content area item

Returns
Type Description
System.String

The html tag for the content area item

GetContentAreaItemTemplateTag(IHtmlHelper, ContentAreaItem)

Gets the template tag for the ContentAreaItem. If a tag is defined on the display options for the ContentAreaItem then that is used; otherwise it uses the content areas template tag.

Declaration
protected virtual string GetContentAreaItemTemplateTag(IHtmlHelper htmlHelper, ContentAreaItem contentAreaItem)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The html helper

ContentAreaItem contentAreaItem

The content area item

Returns
Type Description
System.String

The template tag for the content area item

GetContentAreaTemplateTag(IHtmlHelper)

Gets the template tag for the ContentArea. Looks in the view data for the RenderSettings.Tag setting.

Declaration
protected virtual string GetContentAreaTemplateTag(IHtmlHelper htmlHelper)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The html helper

Returns
Type Description
System.String

The template tag

IsInEditMode()

Determines if the request context is in edit mode.

Declaration
protected virtual bool IsInEditMode()
Returns
Type Description
System.Boolean
true
if the context is in edit mode; otherwise
false

IsInEditMode(IHtmlHelper)

Determines if the request context is in edit mode.

Declaration
protected virtual bool IsInEditMode(IHtmlHelper htmlHelper)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The html helper

Returns
Type Description
System.Boolean
true
if the context is in edit mode; otherwise
false

Render(IHtmlHelper, ContentArea)

Renders the ContentArea to the writer on the current Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.

Declaration
public virtual void Render(IHtmlHelper htmlHelper, ContentArea contentArea)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The Html helper

ContentArea contentArea

The content area

RenderContentAreaItem(IHtmlHelper, ContentAreaItem, String, String, String)

Render a ContentAreaItem.

Declaration
protected virtual void RenderContentAreaItem(IHtmlHelper htmlHelper, ContentAreaItem contentAreaItem, string templateTag, string htmlTag, string cssClass)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The html helper

ContentAreaItem contentAreaItem

The content area item to render

System.String templateTag

The template tag used to resolve the display template

System.String htmlTag

The html tag for the element wrapping the display template

System.String cssClass

The css class for the element wrapping the display template

RenderContentAreaItems(IHtmlHelper, IEnumerable<ContentAreaItem>)

Render the ContentAreaItems.

Declaration
protected virtual void RenderContentAreaItems(IHtmlHelper htmlHelper, IEnumerable<ContentAreaItem> contentAreaItems)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The html helper

System.Collections.Generic.IEnumerable<ContentAreaItem> contentAreaItems

The content area items to render

ResolveTemplate(IHtmlHelper, IContent, IEnumerable<String>)

Resolve the template for the ContentAreaItem based on the template tag.

Declaration
protected virtual TemplateModel ResolveTemplate(IHtmlHelper htmlHelper, IContent content, IEnumerable<string> templateTags)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The html helper

IContent content

The content.

System.Collections.Generic.IEnumerable<System.String> templateTags

The template tags used to resolve the display template

Returns
Type Description
TemplateModel

A template model

ShouldRenderWrappingElement(IHtmlHelper)

Determine whether a container element should be rendered around the content fragments. Looks in the view data for the RenderSettings.HasContainerElement setting. Defaults to true if not defined.

Declaration
protected virtual bool ShouldRenderWrappingElement(IHtmlHelper htmlHelper)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper

The html helper

Returns
Type Description
System.Boolean

The value set in the view data; otherwise true

Extension Methods