Tokens: is there one that handles HTML tag removal?

Topics: Customizing Orchard, General, Troubleshooting, Writing modules
Jul 24, 2014 at 2:15 AM
I have a Text Field [Display options=Html] attached to a content type. I am currently playing with Onestop.Seo that uses patterns [same as autoroute tokens imagine], cruxt of
my questions is: Is there a token modifier that strips the HTML tags from such fields, essentially leaving just the text? Or how would one go about such? Thanks for any support, cheers Dyr
Jul 24, 2014 at 10:17 AM
For those who may'be interested, I just added another class to Tokens Module -- Works nicely:
using System;
using System.Text.RegularExpressions;
using System.Web;
using Orchard.Localization;

namespace Orchard.Tokens.Providers {
    public class HtmlTokens : ITokenProvider {
        public HtmlTokens() {
            T = NullLocalizer.Instance;

        public Localizer T { get; set; }

        public void Describe(DescribeContext context) {
            context.For("Text", T("Text"), T("Tokens for text strings"))
                .Token("HtmlRemove", T("Html Remove"), T("Removes HTML Tags from string."), "Text")

        public void Evaluate(EvaluateContext context) {
            context.For<String>("Text", () => "")
                .Token("HtmlRemove", text => Regex.Replace(text, "<[^>]*(>|$)", string.Empty))
Thanks guys, hope this helps someone - cheers Dyr