Glass.Mapper.Sc.IGlassHtml provides access to helper methods that can be used to rendering content easily in MVC Views and Web Form controls.

You might be asking why do you need a helper class to render content? In the exercises that you have completed you have not need to use one.

It is possible to render content without using IGlassHtml but if you want to take full advantage of the Experience Editor or save yourself time when rendering a field then you must use IGlassHtml. IGlassHtml provides the following featues:

  • Enable Page Editor support for Sitecore fields
  • Render Glass.Mapper.Sc.Fields.Image model properties
  • Render Glass.Mapper.Sc.Fields.Link model properties
  • Create Edit Frames based on your model
  • Access Rendering Parameters

Accessing from Sitecore MVC

When working with Sitecore MVC there are multiple ways to access the IGlassHtml helper.

The first method is via the IMvcContext interfaces:

The other way to access it, and the more common way is using the CSHTML helper method:

Complete and Continue