Available Mustache helpers

Comparison and logic

These helpers allow you to conditionally display data, compare values, or apply logic inside templates. They are especially useful when rendering values based on states, flags, or patterns.

Helper: IIf

Purpose: Inline conditional: if condition is true, return the second argument; otherwise, return the third.

Syntax: {{ IIf condition, value_if_true, value_if_false }}

JSON input:

{
  "is_admin": true
}

Template:

<p>Access: {{ IIf is_admin, "Administrator", "Standard user" }}</p>

Result:

<p>Access: Administrator</p>

If is_admin was false, the result would be Standard user.

You can also use constants or strings directly:

{{ IIf true, "✓", "✗" }} → ✓

Helper: If_

Purpose: Advanced conditional expression. Takes three arguments: If_(condition, then_value, else_value)

It’s similar to IIf, but supports more flexible comparisons when combined with Equals_, Match, etc.

JSON input:

{
  "os": "Windows"
}

Template:

<p>{{ If_(Equals_ os "Windows"), "🪟 Windows detected", "Other OS" }}</p>

Result:

<p>🪟 Windows detected</p>

Helper: Equals_

Purpose: Compares two values for equality. Often used inside If_ or IIf.

JSON input:

{
  "status": "running"
}

Template:

{{#Equals_ status "running"}}
  <p>Service is active</p>
{{/Equals_}}

Result:

<p>Service is active</p>

Helper: Match

Purpose: Tests if a string matches a regular expression (case sensitive).

JSON input:

{
  "version": "v1.2.3"
}

Template:

{{#Match version "=v1\\."}}
  <p>Version 1.x detected</p>
{{/Match}}

Result:

<p>Version 1.x detected</p>

If the pattern doesn’t match (e.g., version is “v2.0”), nothing is shown.

Helper: MatchI

Purpose: Same as Match, but case*insensitive.

JSON input:

{
  "env": "Production"
}

Template:

{{#MatchI env "production"}}
  <p>Production environment</p>
{{/MatchI}}

Result:

<p>Production environment</p>

List and object operations

These helpers are useful when working with lists or dictionaries (objects). They allow iteration, extraction, and transformation of structured data in Mustache templates.

Helper: Items

Purpose: Converts a dictionary into a list of key*value pairs so it can be iterated in Mustache.

JSON input:

{
  "services": {
    "WAPT": "running",
    "Antivirus": "stopped"
  }
}

Template:

<ul>
  {{#Items services}}
    <li>{{key}}: {{value}}</li>
  {{/Items}}
</ul>

Result:

<ul>
  <li>WAPT: running</li>
  <li>Antivirus: stopped</li>
</ul>

Helper: Get

Purpose: Retrieves a value from a dictionary by key, with an optional default value if the key is missing.

JSON input:

{
  "settings": {
    "theme": "dark"
  }
}

Template:

<p>Theme: {{ Get settings, "theme", "light" }}</p>
<p>Language: {{ Get settings, "lang", "en" }}</p>

Result:

<p>Theme: dark</p>
<p>Language: en</p>

Helper: Count

Purpose: Counts the number of elements in a list or the number of keys in a dictionary.

JSON input:

{
  "disks": ["C:", "D:", "E:"]
}

Template:

<p>Number of disks: {{ Count disks }}</p>

Result:

<p>Number of disks: 3</p>

Helper: Values

Purpose: Extracts the values of a dictionary as a list.

JSON input:

{
  "apps": {
    "firefox": "browser",
    "vlc": "media"
  }
}

Template:

<ul>
  {{#Values apps}}
    <li>{{.}}</li>
  {{/Values}}
</ul>

Result:

<ul>
  <li>browser</li>
  <li>media</li>
</ul>

Helper: Keys

Purpose: Extracts the keys of a dictionary as a list.

JSON input:

{
  "apps": {
    "firefox": "browser",
    "vlc": "media"
  }
}

Template:

<ul>
  {{#Keys apps}}
    <li>{{.}}</li>
  {{/Keys}}
</ul>

Result:

<ul>
  <li>firefox</li>
  <li>vlc</li>
</ul>

Helper: First

Purpose: Extracts the first n items from a list.

JSON input:

{
  "users": ["alice", "bob", "carol"]
}

Template:

<ul>
  {{#First users, 2}}
    <li>{{.}}</li>
  {{/First}}
</ul>

Result:

<ul>
  <li>alice</li>
  <li>bob</li>
</ul>

Helper: Last

Purpose: Extracts the last n items from a list.

JSON input:

{
  "logs": ["log1", "log2", "log3", "log4"]
}

Template:

<ul>
  {{#Last logs, 2}}
    <li>{{.}}</li>
  {{/Last}}
</ul>

Result:

<ul>
  <li>log3</li>
  <li>log4</li>
</ul>

Helper: Slice

Purpose: Extracts a sublist from a list using start and end indices.

JSON input:

{
  "items": ["A", "B", "C", "D", "E"]
}

Template:

<ul>
  {{#Slice items, 1, 4}}
    <li>{{.}}</li>
  {{/Slice}}
</ul>

Result:

<ul>
  <li>B</li>
  <li>C</li>
  <li>D</li>
</ul>

Data formatting

These helpers are used to convert raw numerical or structured values into more readable formats, such as human*readable file sizes or CSV tables.

Helper: HumanBytes

Purpose: Converts a byte size (integer) into a human*readable format with units (e.g. KB, MB, GB, etc.).

This helper is extremely useful for displaying disk sizes, memory usage, file sizes, etc.

JSON input:

{
  "disk_size": 1073741824
}

Template:

<p>Total size: {{ HumanBytes disk_size }}</p>

Result:

<p>Total size: 1.00 GiB</p>

You can also use it directly in loops:

{{#disks}}
  <li>{{mountpoint}} * {{ HumanBytes size }}</li>
{{/disks}}

Helper: CSV

Purpose: Converts a list of dictionaries into a comma* or semicolon*separated text (CSV format).

This is useful for exporting rows of audit data like software lists, users, etc.

Syntax: CSV list, separator, column1, column2, ...

JSON input:

{
  "users": [
    {"name": "Alice", "email": "alice@example.com"},
    {"name": "Bob", "email": "bob@example.com"}
  ]
}

Template:

<pre>{{ CSV users, ";", "name", "email" }}</pre>

Result:

<pre>
  name;email
  Alice;alice@example.com
  Bob;bob@example.com
</pre>

You can also use a comma or tab as the separator:

{{ CSV users, ",", "name", "email" }}

String and text manipulation

These helpers allow you to transform or reformat text values before display. They are useful for cleaning raw values, formatting labels, or adjusting alignment.

Helper: Lower

Purpose: Converts a string to lowercase.

JSON input:

{
  "username": "AdminUser"
}

Template:

<p>Login (lowercase): {{ Lower username }}</p>

Result:

<p>Login (lowercase): adminuser</p>

Helper: Upper

Purpose: Converts a string to uppercase.

JSON input:

{
  "department": "it support"
}

Template:

<p>DEPARTMENT: {{ Upper department }}</p>

Result:

<p>DEPARTMENT: IT SUPPORT</p>

Helper: Pad

Purpose: Pads a string on the right to reach a given width. Optional third argument sets the fill character.

JSON input:

{
  "value": "WAPT"
}

Template:

<pre>{{ Pad value, 10, "." }}</pre>

Result:

<pre>WAPT......</pre>

Helper: PadLeft

Purpose: Pads a string on the left to reach a given width. Useful for aligning numbers.

JSON input:

{
  "id": "42"
}

Template:

<pre>{{ PadLeft id, 5, "0" }}</pre>

Result:

<pre>00042</pre>

Helper: Sub

Purpose: Extracts a substring from a string. Arguments: string, start, and optionally length.

JSON input:

{
  "serial": "ABC123456789"
}

Template:

<p>Short serial: {{ Sub serial, 3, 6 }}</p>

Result:

<p>Short serial: 123456</p>

Helper: CamelCase

Purpose: Converts a string to camelCase. Useful for variable naming or display standardization.

JSON input:

{
  "title": "system audit summary"
}

Template:

<p>Var: {{ CamelCase title }}</p>

Result:

<p>Var: systemAuditSummary</p>

Helper: SnakeCase

Purpose: Converts a string to snake_case (lowercase + underscores).

JSON input:

{
  "title": "System Audit Summary"
}

Template:

<p>Key: {{ SnakeCase title }}</p>

Result:

<p>Key: system_audit_summary</p>

Helper: EnumTrim

Purpose: Cleans up enumerated strings like [0] Active, removing the bracketed prefix.

JSON input:

{
  "status": "[1] Enabled"
}

Template:

<p>Status: {{ EnumTrim status }}</p>

Result:

<p>Status: Enabled</p>

Helper: EnumTrimRight

Purpose: Like EnumTrim, but trims bracketed values only from the right side of the string.

JSON input:

{
  "label": "Mode [2]"
}

Template:

<p>Mode: {{ EnumTrimRight label }}</p>

Result:

<p>Mode: Mode</p>

Date and time formatting

These helpers are used to format dates, times, or durations. They’re especially useful for rendering audit fields like installation dates, boot times, or update durations.

Helper: LocalTime

Purpose: Converts a UTC time or datetime into a localized time only, without the date part.

This is useful when you want to show the time of an event (e.g., boot time, user login time), independently of the date.

JSON input:

{
  "last_logon": "2024*04*15T06:45:00Z"
}

Template:

<p>Last logon time: {{ LocalTime last_logon }}</p>

Result:

<p>Last logon time: 08:45:00</p>

(Assuming local time is UTC+2)

If the input is a date string without a time component, the result will default to 00:00:00 (midnight).

Helper: LocalDate

Purpose: Converts a UTC date or datetime into a local date only, in YYYY*MM*DD format.

JSON input:

{
  "install_date": "2023*12*15T14:50:00Z"
}

Template:

<p>Installed on: {{ LocalDate install_date }}</p>

Result:

<p>Installed on: 2023*12*15</p>

Helper: DateFmt

Purpose: Formats a date using a custom pattern, similar to strftime. Input can be a UTC string or timestamp, and you pass the format string as second argument.

JSON input:

{
  "build_time": "2024*04*12T11:00:00Z"
}

Template:

<p>Build date: {{ DateFmt build_time, "%d/%m/%Y" }}</p>

Result:

<p>Build date: 12/04/2024</p>

Helper: DateTimeToText

Purpose: Converts a full datetime into a human*readable string (e.g., “Friday 5 April 2024, 08:35”).

JSON input:

{
  "last_check": "2024*04*05T08:35:00Z"
}

Template:

<p>Last check: {{ DateTimeToText last_check }}</p>

Result:

<p>Last check: Friday 5 April 2024, 08:35</p>

(Formatting depends on the locale used)

Helper: DateToText

Purpose: Converts a date string into readable text format (simpler variant of DateTimeToText, legacy style).

JSON input:

{
  "release_date": "2024*02*01"
}

Template:

<p>Release: {{ DateToText release_date }}</p>

Result:

<p>Release: Thursday 1 February 2024</p>

Helper: TimeLogToText

Purpose: Parses a log time delta string (e.g. “00:04:32”) and converts it to a human*readable format.

JSON input:

{
  "uptime": "00:04:32"
}

Template:

<p>System uptime: {{ TimeLogToText uptime }}</p>

Result:

<p>System uptime: 4 minutes, 32 seconds</p>

HTML and rendering

These helpers let you safely display structured data, escape it, or convert markup formats (Markdown, Wiki, etc.) into HTML for display in templates.

Helper: ToJson2

Purpose: Converts a value (usually a dictionary or list) into pretty printed JSON for display.

It adds indentation and spacing for readability — very useful for debugging or showing structured data.

JSON input:

{
  "network": {
    "ip": "192.168.1.10",
    "mask": "255.255.255.0"
  }
}

Template:

<pre>{{ ToJson2 network }}</pre>

Result:

  <pre>{
"ip": "192.168.1.10",
"mask": "255.255.255.0"
  }
</pre>

Helper: ToJson

Purpose: Converts a value to compact JSON (without formatting). Use it when embedding JSON in JavaScript or HTML attributes.

JSON input:

{
  "cpu": {
    "cores": 4,
    "model": "Intel"
  }
}

Template:

<code>{{ ToJson cpu }}</code>

Result:

<code>{"cores":4,"model":"Intel"}</code>

Helper: JsonQuote

Purpose: Escapes JSON content to safely include it inside an HTML or JavaScript string. Escapes quotes, backslashes, etc.

JSON input:

{
  "path": "C:\\Program Files\\WAPT"
}

Template:

<script>
    var path = "{{ JsonQuote path }}";
</script>

Result:

<script>
    var path = "C:\\\\Program Files\\\\WAPT";
</script>

Helper: JsonQuoteUri

Purpose: Escapes JSON content for use inside a URL. It percent encodes special characters.

JSON input:

{
  "search": "disk space (C:)"
}

Template:

<a href="/search?q={{ JsonQuoteUri search }}">Search</a>

Result:

<a href="/search?q=disk%20space%20%28C%3A%29">Search</a>

Helper: SimpleToHtml

Purpose: Converts plain text with line breaks into basic HTML (<br> tags, no Markdown support).

Useful for displaying audit logs or raw output from commands.

JSON input:

{
  "log": "Update started\nSuccess\nReboot required"
}

Template:

<div>{{ SimpleToHtml log }}</div>

Result:

<div>Update started<br>Success<br>Reboot required</div>

Helper: MarkdownToHtml

Purpose: Parses a Markdown string and renders it as HTML. Supports headers, lists, bold, etc.

JSON input:

{
  "note": "# Status\n* OK\n* Warning\n* Error"
}

Template:

<div class="markdown">{{ MarkdownToHtml note }}</div>

Result:

<div class="markdown">
    <h1>Status</h1>
    <ul>
        <li>OK</li>
        <li>Warning</li>
        <li>Error</li>
    </ul>
</div>

Helper: WikiToHtml

Purpose: Parses a Wiki*style string (similar to DokuWiki or MediaWiki syntax) and renders it as HTML.

JSON input:

{
  "doc": "== Info ==\nThis **device** is _critical_!"
}

Template:

<div class="wiki">{{ WikiToHtml doc }}</div>

Result:

<div class="wiki">
    <h2>Info</h2>
    <p>This <strong>device</strong> is <em>critical</em>!</p>
</div>

Other utilities

These helpers provide general*purpose functions useful for formatting or generating dynamic values.

Helper: JoinValues

Purpose: Joins the values of a list (or dictionary) into a single string using a custom separator.

JSON input:

{
  "packages": ["firefox", "vlc", "notepad++"]
}

Template:

<p>Installed: {{ JoinValues packages, ", " }}</p>

Result:

<p>Installed: firefox, vlc, notepad++</p>

Works with values in a dictionary as well:

{
  "apps": {
    "1": "WAPT",
    "2": "Chrome"
  }
}

Template:

<p>Apps: {{ JoinValues apps, " | " }}</p>

Result:

<p>Apps: WAPT | Chrome</p>

Helper: Join

Purpose: Joins the items of a list or the keys of a dictionary using a separator.

JSON input:

{
  "groups": ["admins", "users", "guests"]
}

Template:

<p>Groups: {{ Join groups, " * " }}</p>

Result:

<p>Groups: admins * users * guests</p>

With a dictionary:

{
  "users": {
    "u1": "Alice",
    "u2": "Bob"
  }
}

Template:

<p>User IDs: {{ Join users, ", " }}</p>

Result:

<p>User IDs: u1, u2</p>

Helper: NewGuid

Purpose: Generates a random UUID (Universally Unique Identifier). Useful for tagging data or testing.

Template:

<p>Generated ID: {{ NewGuid }}</p>

Result:

<p>Generated ID: a8f9e870*3d3c*4a71*91e9*52a4572282e9</p>

Helper: ExtractFileName

Purpose: Extracts the file name from a full path.

JSON input:

{
  "filepath": "C:/Program Files/WAPT/wapt.exe"
}

Template:

<p>File: {{ ExtractFileName filepath }}</p>

Result:

<p>File: wapt.exe</p>

Encoding and hashing

These helpers allow you to encode/decode strings, binary content, or generate hashes. They are especially useful for working with logs, identifiers, images, or URLs in audit reports.

Helper: b64encode

Purpose: Encodes a plain string into base64 format.

JSON input:

{
  "password": "secret123"
}

Template:

<p>Encoded password: {{ b64encode password }}</p>

Result:

<p>Encoded password: c2VjcmV0MTIz</p>

Helper: sha256

Purpose: Calculates the SHA*256 hash of a string. Commonly used for integrity checks or anonymization.

JSON input:

{
  "serial": "ABC123456"
}

Template:

<p>SHA256: {{ sha256 serial }}</p>

Result:

<p>SHA256: b7f51c2... (64 characters)</p>

Helper: sha1

Purpose: Computes the SHA*1 hash of a string (legacy use).

JSON input:

{
  "username": "admin"
}

Template:

<p>SHA1: {{ sha1 username }}</p>

Result:

<p>SHA1: d033e22ae348aeb5660fc2140aec35850c4da997</p>

Helper: md5

Purpose: Generates the MD5 hash of a string.

JSON input:

{
  "filename": "report.pdf"
}

Template:

<p>MD5: {{ md5 filename }}</p>

Result:

<p>MD5: 76c7f3b9d5f43a86ad6f9e1a4567ebc3</p>

Helper: BlobToBase64

Purpose: Encodes binary content (e.g., logs, images, attachments) to base64.

Used internally when embedding binary data inside HTML or JavaScript.

JSON input:

{
  "log_data": "binary_content"
}

Template:

<pre>{{ BlobToBase64 log_data }}</pre>

Result:

<pre>YmFzZTY0IGVuY29kZWQgbG9n...</pre>

Helper: b64decode

Purpose: Decodes a base64*encoded string.

JSON input:

{
  "encoded": "SGVsbG8gd29ybGQh"
}

Template:

<p>Decoded: {{ b64decode encoded }}</p>

Result:

<p>Decoded: Hello world!</p>

Helper: _chr

Purpose: Converts an integer or a list of integers into the corresponding ASCII characters.

This can be used to create control sequences like carriage return (13), newline (10), or even emojis (Unicode values).

JSON input:

{
  "newline": [13, 10]
}

Template:

<pre>{{ _chr newline }}</pre>

Result:

<pre>↵ (carriage return + line feed)</pre>

Another example:

<p>{{ _chr 65 }}</p>

Result:

<p>A</p>

Networking and HTTP

These helpers perform HTTP requests directly from the template. They allow dynamic data fetching from URLs or APIs (internal or external).

⚠️ Warning: These helpers can impact performance and should be used with caution in production templates. Prefer Safe variants when exposing data to users.

Helper: HttpGet

Purpose: Sends a basic HTTP GET request to the given URL.

JSON input:

{
  "url": "https://api.example.com/status"
}

Template:

<p>Status: {{ HttpGet url }}</p>

Result:

<p>Status: {"status":"ok"}</p>

If the response is JSON, it will be returned as a string (not parsed). Use ToJson2 if needed.

Helper: HttpGetSafe

Purpose: Like HttpGet, but with internal validation. Ensures the URL is safe and access is allowed. Preferred in public facing templates.

JSON input:

{
  "url": "https://example.com/uptime.txt"
}

Template:

<p>Uptime: {{ HttpGetSafe url }}</p>

Result:

<p>Uptime: 3 days, 6 hours</p>

Helper: DoHttpGet

Purpose: Lower level version of HttpGet, with optional certificate validation. This version is not recommended in templates — it is used internally.

JSON input:

{
  "url": "https://internal.local/api",
  "verify": "0"
}

Template:

<p>{{ DoHttpGet url, verify }}</p>

Result:

<p>{"message": "OK"}</p>

Helper: HttpPost

Purpose: Sends an HTTP POST request with a payload. The data should be an array: [url, payload].

JSON input:

{
  "post_data": ["https://api.example.com/send", "msg=hello"]
}

Template:

<p>Response: {{ HttpPost post_data }}</p>

Result:

<p>Response: {"status":"received"}</p>

Helper: HttpPostSafe

Purpose: Safe variant of HttpPost, applying domain or content restrictions.

JSON input:

{
  "post_data": ["https://trusted.example.com/api", "data=123"]
}

Template:

<p>{{ HttpPostSafe post_data }}</p>

Result:

<p>{"status":"ok"}</p>

Helper: DoHttpPost

Purpose: Low level variant of HttpPost with optional certificate check.

JSON input:

{
  "args": ["https://local/api", "ping=1"],
  "verify": "0"
}

Template:

<p>{{ DoHttpPost args, verify }}</p>

Result:

<p>{"ping":"ok"}</p>