.. Reminder for header structure: Parts (H1) : #################### with overline Chapters (H2) : ******************** with overline Sections (H3) : ==================== Subsections (H4) : -------------------- Subsubsections (H5) : ^^^^^^^^^^^^^^^^^^^^ Paragraphs (H6) : """"""""""""""""""""" ########################## 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:** .. code-block:: json { "is_admin": true } **Template:** .. code-block:: html
Access: {{ IIf is_admin, "Administrator", "Standard user" }}
**Result:** .. code-block:: htmlAccess: Administrator
If `is_admin` was `false`, the result would be `Standard user`. You can also use constants or strings directly: .. code-block:: html {{ 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:** .. code-block:: json { "os": "Windows" } **Template:** .. code-block:: html{{ If_(Equals_ os "Windows"), "🪟 Windows detected", "Other OS" }}
**Result:** .. code-block:: html🪟 Windows detected
Helper: ``Equals_`` =================== **Purpose:** Compares two values for equality. Often used inside `If_` or `IIf`. **JSON input:** .. code-block:: json { "status": "running" } **Template:** .. code-block:: html {{#Equals_ status "running"}}Service is active
{{/Equals_}} **Result:** .. code-block:: htmlService is active
Helper: ``Match`` ================= **Purpose:** Tests if a string matches a regular expression (case sensitive). **JSON input:** .. code-block:: json { "version": "v1.2.3" } **Template:** .. code-block:: html {{#Match version "=v1\\."}}Version 1.x detected
{{/Match}} **Result:** .. code-block:: htmlVersion 1.x detected
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:** .. code-block:: json { "env": "Production" } **Template:** .. code-block:: html {{#MatchI env "production"}}Production environment
{{/MatchI}} **Result:** .. code-block:: htmlProduction environment
************************** 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:** .. code-block:: json { "services": { "WAPT": "running", "Antivirus": "stopped" } } **Template:** .. code-block:: htmlTheme: {{ Get settings, "theme", "light" }}
Language: {{ Get settings, "lang", "en" }}
**Result:** .. code-block:: htmlTheme: dark
Language: en
Helper: ``Count`` ================= **Purpose:** Counts the number of elements in a list or the number of keys in a dictionary. **JSON input:** .. code-block:: json { "disks": ["C:", "D:", "E:"] } **Template:** .. code-block:: htmlNumber of disks: {{ Count disks }}
**Result:** .. code-block:: htmlNumber of disks: 3
Helper: ``Values`` ================== **Purpose:** Extracts the values of a dictionary as a list. **JSON input:** .. code-block:: json { "apps": { "firefox": "browser", "vlc": "media" } } **Template:** .. code-block:: htmlTotal size: {{ HumanBytes disk_size }}
**Result:** .. code-block:: htmlTotal size: 1.00 GiB
You can also use it directly in loops: .. code-block:: html {{#disks}}{{ CSV users, ";", "name", "email" }}**Result:** .. code-block:: html
name;email Alice;alice@example.com Bob;bob@example.comYou can also use a comma or tab as the separator: .. code-block:: html {{ 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:** .. code-block:: json { "username": "AdminUser" } **Template:** .. code-block:: html
Login (lowercase): {{ Lower username }}
**Result:** .. code-block:: htmlLogin (lowercase): adminuser
Helper: ``Upper`` ================= **Purpose:** Converts a string to uppercase. **JSON input:** .. code-block:: json { "department": "it support" } **Template:** .. code-block:: htmlDEPARTMENT: {{ Upper department }}
**Result:** .. code-block:: htmlDEPARTMENT: IT SUPPORT
Helper: ``Pad`` =============== **Purpose:** Pads a string on the right to reach a given width. Optional third argument sets the fill character. **JSON input:** .. code-block:: json { "value": "WAPT" } **Template:** .. code-block:: html{{ Pad value, 10, "." }}**Result:** .. code-block:: html
WAPT......Helper: ``PadLeft`` =================== **Purpose:** Pads a string on the left to reach a given width. Useful for aligning numbers. **JSON input:** .. code-block:: json { "id": "42" } **Template:** .. code-block:: html
{{ PadLeft id, 5, "0" }}**Result:** .. code-block:: html
00042Helper: ``Sub`` =============== **Purpose:** Extracts a substring from a string. Arguments: `string`, `start`, and optionally `length`. **JSON input:** .. code-block:: json { "serial": "ABC123456789" } **Template:** .. code-block:: html
Short serial: {{ Sub serial, 3, 6 }}
**Result:** .. code-block:: htmlShort serial: 123456
Helper: ``CamelCase`` ===================== **Purpose:** Converts a string to camelCase. Useful for variable naming or display standardization. **JSON input:** .. code-block:: json { "title": "system audit summary" } **Template:** .. code-block:: htmlVar: {{ CamelCase title }}
**Result:** .. code-block:: htmlVar: systemAuditSummary
Helper: ``SnakeCase`` ===================== **Purpose:** Converts a string to snake_case (lowercase + underscores). **JSON input:** .. code-block:: json { "title": "System Audit Summary" } **Template:** .. code-block:: htmlKey: {{ SnakeCase title }}
**Result:** .. code-block:: htmlKey: system_audit_summary
Helper: ``EnumTrim`` ==================== **Purpose:** Cleans up enumerated strings like `[0] Active`, removing the bracketed prefix. **JSON input:** .. code-block:: json { "status": "[1] Enabled" } **Template:** .. code-block:: htmlStatus: {{ EnumTrim status }}
**Result:** .. code-block:: htmlStatus: Enabled
Helper: ``EnumTrimRight`` ========================= **Purpose:** Like `EnumTrim`, but trims bracketed values **only from the right side** of the string. **JSON input:** .. code-block:: json { "label": "Mode [2]" } **Template:** .. code-block:: htmlMode: {{ EnumTrimRight label }}
**Result:** .. code-block:: htmlMode: Mode
************************ 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:** .. code-block:: json { "last_logon": "2024*04*15T06:45:00Z" } **Template:** .. code-block:: htmlLast logon time: {{ LocalTime last_logon }}
**Result:** .. code-block:: htmlLast logon time: 08:45:00
*(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:** .. code-block:: json { "install_date": "2023*12*15T14:50:00Z" } **Template:** .. code-block:: htmlInstalled on: {{ LocalDate install_date }}
**Result:** .. code-block:: htmlInstalled on: 2023*12*15
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:** .. code-block:: json { "build_time": "2024*04*12T11:00:00Z" } **Template:** .. code-block:: htmlBuild date: {{ DateFmt build_time, "%d/%m/%Y" }}
**Result:** .. code-block:: htmlBuild date: 12/04/2024
Helper: ``DateTimeToText`` ========================== **Purpose:** Converts a full datetime into a **human*readable** string (e.g., "Friday 5 April 2024, 08:35"). **JSON input:** .. code-block:: json { "last_check": "2024*04*05T08:35:00Z" } **Template:** .. code-block:: htmlLast check: {{ DateTimeToText last_check }}
**Result:** .. code-block:: htmlLast check: Friday 5 April 2024, 08:35
*(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:** .. code-block:: json { "release_date": "2024*02*01" } **Template:** .. code-block:: htmlRelease: {{ DateToText release_date }}
**Result:** .. code-block:: htmlRelease: Thursday 1 February 2024
Helper: ``TimeLogToText`` ========================= **Purpose:** Parses a **log time delta string** (e.g. `"00:04:32"`) and converts it to a human*readable format. **JSON input:** .. code-block:: json { "uptime": "00:04:32" } **Template:** .. code-block:: htmlSystem uptime: {{ TimeLogToText uptime }}
**Result:** .. code-block:: htmlSystem uptime: 4 minutes, 32 seconds
****************** 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: ``{{> file.ext }}`` =========================== **Purpose:** Includes a partial file (such as HTML, CSS, TXT, PNG, JPG) into the template output. This allows reusable fragments to be shared across multiple templates, like common styles or headers. Partials must be placed in the ``templates/partials/`` directory and can be overridden in the user's AppData template folder. **Example partial (``style.css``):** .. code-block:: css body { background: #f0f0f0; } **Template:** .. code-block:: html {{> style.css }} **Result:** .. code-block:: html 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:** .. code-block:: json { "network": { "ip": "192.168.1.10", "mask": "255.255.255.0" } } **Template:** .. code-block:: html{{ ToJson2 network }}**Result:** .. code-block:: html
{ "ip": "192.168.1.10", "mask": "255.255.255.0" }Helper: ``ToJson`` ================== **Purpose:** Converts a value to compact JSON (without formatting). Use it when embedding JSON in JavaScript or HTML attributes. **JSON input:** .. code-block:: json { "cpu": { "cores": 4, "model": "Intel" } } **Template:** .. code-block:: html
{{ ToJson cpu }}
**Result:**
.. code-block:: html
{"cores":4,"model":"Intel"}
Helper: ``JsonQuote``
=====================
**Purpose:** Escapes JSON content to safely include it inside an HTML or JavaScript string. Escapes quotes, backslashes, etc.
**JSON input:**
.. code-block:: json
{
"path": "C:\\Program Files\\WAPT"
}
**Template:**
.. code-block:: html
**Result:**
.. code-block:: html
Helper: ``JsonQuoteUri``
========================
**Purpose:** Escapes JSON content for use inside a URL. It percent encodes special characters.
**JSON input:**
.. code-block:: json
{
"search": "disk space (C:)"
}
**Template:**
.. code-block:: html
Search
**Result:**
.. code-block:: html
Search
Helper: ``SimpleToHtml``
========================
**Purpose:** Converts plain text with line breaks into basic HTML (`This device is critical!
Installed: {{ JoinValues packages, ", " }}
**Result:** .. code-block:: htmlInstalled: firefox, vlc, notepad++
Works with values in a dictionary as well: .. code-block:: json { "apps": { "1": "WAPT", "2": "Chrome" } } **Template:** .. code-block:: htmlApps: {{ JoinValues apps, " | " }}
**Result:** .. code-block:: htmlApps: WAPT | Chrome
Helper: ``Join`` ================ **Purpose:** Joins the **items** of a list or the **keys** of a dictionary using a separator. **JSON input:** .. code-block:: json { "groups": ["admins", "users", "guests"] } **Template:** .. code-block:: htmlGroups: {{ Join groups, " * " }}
**Result:** .. code-block:: htmlGroups: admins * users * guests
With a dictionary: .. code-block:: json { "users": { "u1": "Alice", "u2": "Bob" } } **Template:** .. code-block:: htmlUser IDs: {{ Join users, ", " }}
**Result:** .. code-block:: htmlUser IDs: u1, u2
Helper: ``NewGuid`` =================== **Purpose:** Generates a random UUID (Universally Unique Identifier). Useful for tagging data or testing. **Template:** .. code-block:: htmlGenerated ID: {{ NewGuid }}
**Result:** .. code-block:: htmlGenerated ID: a8f9e870*3d3c*4a71*91e9*52a4572282e9
Helper: ``ExtractFileName`` =========================== **Purpose:** Extracts the file name from a full path. **JSON input:** .. code-block:: json { "filepath": "C:/Program Files/WAPT/wapt.exe" } **Template:** .. code-block:: htmlFile: {{ ExtractFileName filepath }}
**Result:** .. code-block:: htmlFile: wapt.exe
******************** 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:** .. code-block:: json { "password": "secret123" } **Template:** .. code-block:: htmlEncoded password: {{ b64encode password }}
**Result:** .. code-block:: htmlEncoded password: c2VjcmV0MTIz
Helper: ``sha256`` ================== **Purpose:** Calculates the SHA*256 hash of a string. Commonly used for integrity checks or anonymization. **JSON input:** .. code-block:: json { "serial": "ABC123456" } **Template:** .. code-block:: htmlSHA256: {{ sha256 serial }}
**Result:** .. code-block:: htmlSHA256: b7f51c2... (64 characters)
Helper: ``sha1`` ================ **Purpose:** Computes the SHA*1 hash of a string (legacy use). **JSON input:** .. code-block:: json { "username": "admin" } **Template:** .. code-block:: htmlSHA1: {{ sha1 username }}
**Result:** .. code-block:: htmlSHA1: d033e22ae348aeb5660fc2140aec35850c4da997
Helper: ``md5`` =============== **Purpose:** Generates the MD5 hash of a string. **JSON input:** .. code-block:: json { "filename": "report.pdf" } **Template:** .. code-block:: htmlMD5: {{ md5 filename }}
**Result:** .. code-block:: htmlMD5: 76c7f3b9d5f43a86ad6f9e1a4567ebc3
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:** .. code-block:: json { "log_data": "binary_content" } **Template:** .. code-block:: html{{ BlobToBase64 log_data }}**Result:** .. code-block:: html
YmFzZTY0IGVuY29kZWQgbG9n...Helper: ``b64decode`` ===================== **Purpose:** Decodes a base64*encoded string. **JSON input:** .. code-block:: json { "encoded": "SGVsbG8gd29ybGQh" } **Template:** .. code-block:: html
Decoded: {{ b64decode encoded }}
**Result:** .. code-block:: htmlDecoded: Hello world!
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:** .. code-block:: json { "newline": [13, 10] } **Template:** .. code-block:: html{{ _chr newline }}**Result:** .. code-block:: html
↵ (carriage return + line feed)Another example: .. code-block:: html
{{ _chr 65 }}
**Result:** .. code-block:: htmlA
******************* 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:** .. code-block:: json { "url": "https://api.example.com/status" } **Template:** .. code-block:: htmlStatus: {{ HttpGet url }}
**Result:** .. code-block:: htmlStatus: {"status":"ok"}
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:** .. code-block:: json { "url": "https://example.com/uptime.txt" } **Template:** .. code-block:: htmlUptime: {{ HttpGetSafe url }}
**Result:** .. code-block:: htmlUptime: 3 days, 6 hours
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:** .. code-block:: json { "url": "https://internal.local/api", "verify": "0" } **Template:** .. code-block:: html{{ DoHttpGet url, verify }}
**Result:** .. code-block:: html{"message": "OK"}
Helper: ``HttpPost`` ==================== **Purpose:** Sends an HTTP POST request with a payload. The data should be an array: `[url, payload]`. **JSON input:** .. code-block:: json { "post_data": ["https://api.example.com/send", "msg=hello"] } **Template:** .. code-block:: htmlResponse: {{ HttpPost post_data }}
**Result:** .. code-block:: htmlResponse: {"status":"received"}
Helper: ``HttpPostSafe`` ======================== **Purpose:** Safe variant of `HttpPost`, applying domain or content restrictions. **JSON input:** .. code-block:: json { "post_data": ["https://trusted.example.com/api", "data=123"] } **Template:** .. code-block:: html{{ HttpPostSafe post_data }}
**Result:** .. code-block:: html{"status":"ok"}
Helper: ``DoHttpPost`` ====================== **Purpose:** Low level variant of `HttpPost` with optional certificate check. **JSON input:** .. code-block:: json { "args": ["https://local/api", "ping=1"], "verify": "0" } **Template:** .. code-block:: html{{ DoHttpPost args, verify }}
**Result:** .. code-block:: html{"ping":"ok"}