RazorTemplateBase Extension or Partial. Access property and method.

Sep 18, 2012 at 6:45 PM

Hello,

I created a template where inside I have two versions: HTML and PLAIN Text.

The version that is rendered is based on the Property Format of the template.

Before calling TransformText I need to define the value of that property.

I was trying to make this work using Extensions or defining a RazorTemplateBase partial class ... But until now I wasn't able to define the Format property common to all templates.

Consider the Extensions I was creating:

  public static class RazorTemplateBaseExtensions {

    public static String ToHtml(this RazorTemplateBase value) {

      // Define Property Format of template (value) passed
      return value.TransformText();

    }

    public static String ToText(this RazorTemplateBase value) {

      // Define Property Format of template (value) passed
      return value.TransformText();

    }

  } // RazorTemplateBaseExtensions

Is there a way to make this work? Or with the Partial Class?

Thank You,

Miguel