SaaS CMS has officially launched! Learn more now.

Class ContentRenderingContext

Keeps track of the current context during rendering. This is used e.g. to output edit attributes for correct properties.

Inheritance
System.Object
ContentRenderingContext
Namespace: EPiServer.Web.Templating
Assembly: EPiServer.Cms.AspNetCore.Templating.dll
Version: 12.0.3
Syntax
public class ContentRenderingContext : Object
Remarks

In case rendering is done through helper method PropertyFor then the context is created automatically.

Constructors

ContentRenderingContext(ContentRenderingContext, IContentData, TemplateModel, IEnumerable<String>)

Creates a new instance of ContentRenderingContext.

Declaration
public ContentRenderingContext(ContentRenderingContext parentContext, IContentData content = null, TemplateModel templateModel = null, IEnumerable<string> templateTags = null)
Parameters
Type Name Description
ContentRenderingContext parentContext

The parent context of the current context.

IContentData content

The current content that is rendered.

TemplateModel templateModel

The selected template for rendering

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

A list of the current active display tags.

ContentRenderingContext(ContentRenderingContext, IPropertyDescriptor, TemplateModel, IEnumerable<String>)

Creates a new instance of ContentRenderingContext.

Declaration
public ContentRenderingContext(ContentRenderingContext parentContext, IPropertyDescriptor propertyDescriptor, TemplateModel templateModel = null, IEnumerable<string> templateTags = null)
Parameters
Type Name Description
ContentRenderingContext parentContext

The parent context of the current context.

IPropertyDescriptor propertyDescriptor

A representation of the current property rendered.

TemplateModel templateModel

The selected template for rendering

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

A list of the current active display tags.

ContentRenderingContext(ContentRenderingContext, IPropertyDescriptor, Object, IContentData, TemplateModel, IEnumerable<String>)

Creates a new instance of ContentRenderingContext.

Declaration
public ContentRenderingContext(ContentRenderingContext parentContext, IPropertyDescriptor propertyDescriptor, object model, IContentData contentData = null, TemplateModel templateModel = null, IEnumerable<string> templateTags = null)
Parameters
Type Name Description
ContentRenderingContext parentContext

The parent context of the current context.

IPropertyDescriptor propertyDescriptor

A representation of the current property rendered.

System.Object model

The current model that is rendered.

IContentData contentData

The current content that is rendered.

TemplateModel templateModel

The template model selected for this model

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

A list of the current active display tags.

Fields

ContentRenderingContextKey

Marker to indicate the text which is stored in httpContext.Items.

Declaration
public const string ContentRenderingContextKey = "Epi:ContentRenderingContext"
Field Value
Type Description
System.String

Properties

Content

Gets the current content rendering.

Declaration
public IContentData Content { get; }
Property Value
Type Description
IContentData

The content.

Gets the content reference for current content

Declaration
public ContentReference ContentLink { get; }
Property Value
Type Description
ContentReference

Model

Gets the current model that is rendered.

Declaration
public object Model { get; }
Property Value
Type Description
System.Object
Remarks

When inside the context of rendering a specific property this is the property value.

When current rendering is inside a content context but not inside a specific property (e.g. when a content area item is rendered or top level context) rendering the model is content item.

ParentContext

In case the current model is rendered in context of another model. For example when a content item is rendered within a content area.

Declaration
public ContentRenderingContext ParentContext { get; }
Property Value
Type Description
ContentRenderingContext

PropertyDescriptor

A representation of the current property rendered.

Declaration
public IPropertyDescriptor PropertyDescriptor { get; }
Property Value
Type Description
IPropertyDescriptor

SelectedTemplate

Gets the current template selected to render this model, if any

Declaration
public TemplateModel SelectedTemplate { get; }
Property Value
Type Description
TemplateModel

TemplateTags

Gets a list of the current active template tags.

Declaration
public IEnumerable<string> TemplateTags { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.String>
Remarks

Tags are combined with display tags from parent context.

Extension Methods