Mustache Template Showcase

This page is a showcase for all the mustache features usable from DMVCFramework Server Side Views using the default Mustache engine.

List of objects

{{^people}}
No People Found
{{/people}} {{#people}}
{{-index}}. {{first_name}} {{last_name}}
{{/people}}

Handle empty list of objects

{{^people2}}
No People Found
{{/people2}} {{#people2}}
{{-index}}. {{first_name}} {{last_name}}
{{/people2}}

Avoid HTML automatic escaping using {{=<% %>=}} {{ content }} <%={{ }}=%>

{{#myobj}} {{{rawhtml}} {{/myobj}}
Check source code to know how to escape curly braces

Handling partials

Using Standard Helpers

{{#people}}
{{-index}}. {{UpperCase first_name}} {{UpperCase LowerCase last_name}}
{{/people}}

dmustache provides the following helpers

DateTimeToText

DateToText

DateFmt

TimeLogToText

JSONQuote

JSONQuoteURI

ToJSON

MarkdownToHtml

SimpleToHtml

WikiToHtml

BlobToBase64

EnumTrim

EnumTrimRight

PowerOfTwo

Equals

If

NewGUID

ExtractFileName

Lower

Upper


DMVCFramework provides some extensions to the dmustache helpers

{{=<% %>=}} {{UpperCase "daniele teti"}} <%={{ }}=%> outputs: {{UpperCase "daniele teti"}}

{{=<% %>=}} {{LowerCase "DANIELE TETI"}} <%={{ }}=%> outputs: {{LowerCase "daniele teti"}}

{{=<% %>=}} {{Capitalize "daniele teti"}} <%={{ }}=%> outputs: {{Capitalize "daniele teti"}}

{{=<% %>=}} {{SnakeCase "daniele teti"}} <%={{ }}=%> outputs: {{SnakeCase "daniele teti"}}

Using Project Specific Helpers

Any project can define its own custom helpers

{{MyHelper1 "this is a text"}}

{{MyHelper2 "this is another text"}}