Last active
March 2, 2020 23:02
-
-
Save nathanwoulfe/974232ee8c62f4bb12e87193bee85647 to your computer and use it in GitHub Desktop.
Processing Umbraco macros
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// Extension on UmbracoHelper to return a processed macro as a string... | |
/// | |
public static IHtmlString RenderMacroScript(this UmbracoHelper helper, string language, string fileLocation, IDictionary<string, object> parameters) | |
{ | |
var ctrl = new umbraco.presentation.templateControls.Macro | |
{ | |
Language = language, | |
FileLocation = fileLocation, | |
}; | |
foreach (var parameter in parameters) | |
{ | |
ctrl.Attributes.Add(parameter.Key, parameter.Value.ToString()); | |
} | |
return new HtmlString(ctrl.RenderControlToString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment