.. 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

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

**Result:**

.. code-block:: html

    <p>Access: Administrator</p>

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

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

**Result:**

.. code-block:: html

    <p>🪟 Windows detected</p>


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"}}
      <p>Service is active</p>
    {{/Equals_}}

**Result:**

.. code-block:: html

    <p>Service is active</p>


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\\."}}
      <p>Version 1.x detected</p>
    {{/Match}}

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

    {
      "env": "Production"
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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


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:: html

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

**Result:**

.. code-block:: html

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


Helper: ``Keys``
================

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

**JSON input:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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


Helper: ``First``
=================

**Purpose:** Extracts the first `n` items from a list.

**JSON input:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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


Helper: ``Last``
================

**Purpose:** Extracts the last `n` items from a list.

**JSON input:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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


Helper: ``Slice``
=================

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

**JSON input:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

    {
      "disk_size": 1073741824
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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

You can also use it directly in loops:

.. code-block:: html

    {{#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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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

You 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

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

**Result:**

.. code-block:: html

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


Helper: ``Upper``
=================

**Purpose:** Converts a string to uppercase.

**JSON input:**

.. code-block:: json

    {
      "department": "it support"
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

    {
      "value": "WAPT"
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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


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

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

**Result:**

.. code-block:: html

    <pre>00042</pre>


Helper: ``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

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

**Result:**

.. code-block:: html

    <p>Short serial: 123456</p>


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:: html

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

**Result:**

.. code-block:: html

    <p>Var: systemAuditSummary</p>


Helper: ``SnakeCase``
=====================

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

**JSON input:**

.. code-block:: json

    {
      "title": "System Audit Summary"
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <p>Key: system_audit_summary</p>


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:: html

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

**Result:**

.. code-block:: html

    <p>Status: Enabled</p>


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:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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: ``{{> 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

    <style>
    body {
      background: #f0f0f0;
    }
    </style>


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

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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

Works with values in a dictionary as well:

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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

With a dictionary:

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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


Helper: ``NewGuid``
===================

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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


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:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

    {
      "password": "secret123"
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

    {
      "serial": "ABC123456"
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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


Helper: ``sha1``
================

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

**JSON input:**

.. code-block:: json

    {
      "username": "admin"
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <p>SHA1: d033e22ae348aeb5660fc2140aec35850c4da997</p>


Helper: ``md5``
===============

**Purpose:** Generates the MD5 hash of a string.

**JSON input:**

.. code-block:: json

    {
      "filename": "report.pdf"
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

    {
      "log_data": "binary_content"
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <pre>YmFzZTY0IGVuY29kZWQgbG9n...</pre>


Helper: ``b64decode``
=====================

**Purpose:** Decodes a base64*encoded string.

**JSON input:**

.. code-block:: json

    {
      "encoded": "SGVsbG8gd29ybGQh"
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

    {
      "newline": [13, 10]
    }

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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

Another example:

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

    <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:**

.. code-block:: json

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

**Template:**

.. code-block:: html

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

**Result:**

.. code-block:: html

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


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

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

**Result:**

.. code-block:: html

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


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

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

**Result:**

.. code-block:: html

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