RenderMacro and MVC Razor

working with the 'Macro Container DataType' with MVC razor

Posted on Thursday, July 24, 2014


I earlier versions of Umbraco it seemed easy enough to use a Macro container as part of page template.

@Umbraco.Field("renderMacro")

This outputed (for example):

 <?UMBRACO_MACRO macroalias="AccordianForTools" nodeId="1463" />

While upgrading a site to v.6.2.1 running MVC engine the @Umbraco.Field("renderMacro") within a page template (view) did not render anything.

Turns out there is an Umbraco Library helpers there is this method that can be used to display the macros from a macro container.

i.e.

@Html.Raw(umbraco.library.RenderMacroContent(CurrentPage.renderMacro, CurrentPage.Id))

This is listed as an bug/issue : http://issues.umbraco.org/issue/U4-5273

(fix due in 6.2.2)