Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

Remove New line character from XHTMLString response

$
0
0

I am using Content Delivery API that works fine. For some reason there is a need to remove the new line characters from the xhtml string response.

Based on this article  https://world.episerver.com/documentation/developer-guides/content-delivery-api/serialization/ I tried to remove the new line character but I still see it in response.

What am I missing. Here is what I have

[ServiceConfiguration(typeof(IPropertyModelConverter), Lifecycle = ServiceInstanceScope.Singleton)]
public class CustomXhtmlStringUpdate : DefaultPropertyModelConverter
{
public CustomXhtmlStringUpdate() => ModelTypes = new List<TypeModel>
{
new TypeModel
{
ModelType = typeof(CustomHtmlStringPropertyModel), ModelTypeString = nameof(CustomHtmlStringPropertyModel), PropertyType = typeof(PropertyXhtmlString)
}
};
}

public class CustomHtmlStringPropertyModel : PropertyModel<string, PropertyXhtmlString>
{
public CustomHtmlStringPropertyModel(PropertyXhtmlString propertyXhtmlString) : base(propertyXhtmlString)
{
if (propertyXhtmlString != null)
{
Value = propertyXhtmlString.ToString().Replace(Environment.NewLine, "");
}
}
}


Viewing all articles
Browse latest Browse all 6894

Trending Articles