Developer forum

Forum » CMS - Standard features » How to strip html / html decode in razor?

How to strip html / html decode in razor?

Hans Ravnsfjall
Reply

Hi

In html templates, it is possible to add .StripHtml().HtmlDecoded().Crop(100) to a tag, to avoid breaking of nordic charachters like Æ and Ø

How can i do this in razor to a variable that is declared like this?

string  Description = product.GetString("Ecom:Product.ShortDescription");

and called like this

@WrapMethods.Truncate(product.GetString("Ecom:Product.ShortDescription"), 40)

 

As you can see this is a wrap solution, but it is a general Razor question.

 

regards, Hans


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Hans

You can do like this:

@WrapMethods.Truncate(System.Web.HttpUtility.HtmlDecode(Dynamicweb.Base.StripHTML(product.GetString("Ecom:Product.ShortDescription"))), 40)

Votes for this answer: 1
 
Hans Ravnsfjall
Reply

That´s perfect :)

 

have a nice weekend

 

You must be logged in to post in the forum