Encoding extensions

If you use Razor you have access to the full spectrum of C# methods - e.g. the String.StartsWith Method (String).

For the less powerful HTML-based template tag system, you can use a series of encoding extensions to format your data.

These are the encoding extensions available to you:

*.HtmlEncoded()

HTML encodes the output.

*.UrlEncoded()

URL encodes the output.

*.JSEncoded()

Escapes ' and " in value.

*.Raw()

Does not encode if default htmlencoding is set to true).

*.Length()

Returns the length of the tag value.

*.StripHtml()

Removes the HTML.

*.Remove(startIndex)

Removes all characters from startIndex to end of string. Returns a string no longer than the passed integer, i.e: 
*.Remove(30) will return only the first 30 characters. If only 20 is present, 20 will be returned.

*.Remove(startIndex, count)

Removes count characters from start index.

*.Replace(oldValue, newValue)

Replaces oldValue with newValue in the tag.

*.ToLower()

Converts to lower case.

*.ToUpper()

Converts to upper case.

*.Contains(value)

Returns True if tag value contains value.

*.StartsWith(value)

Returns True if tag value starts with value.

*.EndsWith(value)

Returns True if tag value end with value.

*.Substring(startIndex)

Returns substring starting at the startIndex position in the current string.

*.Substring(startIndex, length)

Returns substring with length characters starting from the startIndex position in the current string.

*.Crop(length)

Crops to length characters and appends … (three dots)

*.Format(format)

Formats tag value using String.Format(format, value)

*.FormatDouble(format)

Same as *.Format, but converts tag value to a double before formatting.

*.FormatInteger(format)

Same as *.Format, but converts tag value to an integer before formatting.

*.FormatDate(format)

Same as *.Format, but converts tag value to a date before formatting.

*.IndexedValue()

Gets an indexed value of the template tag. The value of the tag will be splittet on new lines or ; and will return first item 0, then 1 until N and restart the list.

For SEO purposes to use different terms on the same button, i.e. instead of "Compare" 10 times, using "Compare product", "Compare item" etc. 

HTML encoding can be enabled by default in a template using this tag: 

HTML
<!--@HtmlEncodeTagValues=True-->

Use .Raw to get the unencoded value of the tag.

Please note, that it is not possible to use If tags on .HtmlEncoded and .UrlEncoded.