[stringtemplate-interest] Html encoding

brian at protexis.com brian at protexis.com
Tue Aug 1 11:34:45 PDT 2006


Hi

When using string template to render html, some of the attributes need to
be html encoded and some do not. At present, I create wrapper classes to
perform the encoding. Does anyone have a simpler or cleaner solution.

Thanks

For example ...

Here's the wrapper class ...

internal class StructureWrapper
{
  Structure m_structure;

  internal StructureWrapper(Structure structure)
  {
    this.m_structure = structure;
  }

  internal string NeedsEncoding
  {
    get { return SomeHtmlEncodingFunction(m_structure.ValueOne); }
  }

  internal string DoesNotNeedEncoding
  {
    get { return m_structure.ValueTwo; }
  }
}

Here's the set attribute ...

stringTemplate.SetAttribute("structure", structureWrapper);

Here's the st file ...



$structure.NeedsEncoding$









More information about the stringtemplate-interest mailing list