Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Umbraco - Overrides the default MacroContainerValueConverter, to return the correct type, HtmlString
using System;
using Umbraco.Core;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.ValueConverters;
using Umbraco.Web.PropertyEditors.ValueConverters;
namespace Our.Umbraco.Web.HotFixes
{
public class MyApplicationEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
PropertyValueConvertersResolver.Current.RemoveType<MacroContainerValueConverter>();
}
}
public class MyMacroContainerValueConverter : MacroContainerValueConverter
{
public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
{
var value = base.ConvertDataToSource(propertyType, source, preview);
return value != null ? new HtmlString(value.ToString()) : source;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.