Modifiers

Called via the pipe symbol |. Parameters are passed via a colon :. Modifiers can be chained: {VAR|mod1|mod2:param}.

⚠️ Case in variable-reference parameters: If a modifier parameter is a variable name or field key rather than static text (as in calc, print, array_item), the parser looks for it in exactly the case it is written — no automatic uppercasing occurs. All data keys in the templating engine (including nested arrays passed via TplAssign and the global array) are stored in UPPERCASE, so such parameters must also be written in uppercase: {ROW|calc:PRICE*2}, not {ROW|calc:price*2} — otherwise the name will not be found.

Text and HTML

Order matters: tag does not escape the content of the value — if it came from a user (untrusted HTML), apply |html first, and only then |tag: {USER_COMMENT|html|tag:span,comment}.

Formatted Output

Numbers and Math

Dates

Multilingual Formats (intl)

These modifiers automatically adapt output formats to the current page language (MELBIS()->LanguageSet('en')), using the ICU library. Ideal for projects with en, ru, ua, etc.

Arrays and JSON

If the path in array_item/json_item points not to a final scalar value but to a nested array/object — the result will be an array; combine with |join if a string is needed.

System Functions

Calling Standard PHP Functions

The parser allows passing a variable’s value through any available PHP function (unless it is blocked for security reasons).

Escaping Special Characters in Modifier Parameters

Since comma, colon, |, {, } and space are used by the parser itself as service delimiters, you can pass them literally in a parameter (e.g., the delimiter in split or a value in style for tag) using special substitutions:

Substitution Character
_nl_ newline
_sp_ space
_cl_ :
_cm_ ,
_pl_ |
_bo_ {
_bc_ }

For example, {TEXT|split:_cm_,1} will split the string by a literal comma (not the service one), and {VAR|tag:span,,font-family: Arial_cm_ sans-serif} will insert a real comma into the style value.

How arguments are passed:

Syntax: {VARIABLE|function_name:param2,param3}

Usage examples:

A practically important case that is not obvious from the general rule: {QUERY|rawurlencode} — encoding for a path segment, unlike [QUERY] (see “Template Syntax”).

Passing an array as a module call argument. Serialize the array in PHP, and pass the ready string to the template — the receiving module will declare the parameter as type serial, and the parser will automatically expand it back into an array:

$filters_line = serialize($filters);
MELBIS()->TplAssign($tpl, 'FILTERS', $filters_line);
{MELBIS:goods_navi([TOTAL],[PAGE_NUM],[FILTERS])}

Square brackets are mandatory: a serialized string is full of quotes, colons and curly braces, and without urlencode the argument list parsing will break. The parser performs the reverse urldecode itself when parsing a serial parameter.

Serialize in PHP, not with a modifier in the template: TplAssign converts all array keys to uppercase, so serialize inside a tag would save keys as ORDER, PRICE rather than the original order, price.

⚠️ Case in parameters when they are array keys: For standard PHP functions, parameters are passed literally, as you wrote them — the parser does not look them up in context and does not convert them to uppercase (unlike calc/print/array_item, where the parameter is a variable name that the engine itself finds in the UPPERCASE context). If a function’s parameter is a key that the function itself uses to look inside an array string (like the second argument of array_column), it must match the actual case of your data keys, and those, having passed through TplAssign, are always in UPPERCASE:

{STORE|array_column:id|join}   — won't work, returns empty string: array_column looks for key 'id',
                                  but in STORE rows the key is named 'ID'
{STORE|array_column:ID|join}   — works: the parameter case matches the actual key

This is not the same rule as the case of parameters in calc/print/array_item (there the reason is the engine searching for a variable), but in practice both cases require writing the parameter in uppercase.

Calling Custom Functions (Module Callbacks)

For complex business logic (e.g., string translation, multi-currency support, specific formatting) you can register your own functions. They are called via a modifier starting with the $ sign (e.g., |$trans).

The callback mechanism uses strict registration and passes all data to the function as a single associative array, allowing flexible combination of template variables and system settings.

1. Registering Functions in PHP

There are two levels of registration: global and local (at the level of a specific module).

MELBIS()->DefineCallback('trans', 'MELBIS_INC_translate', ['from' => 'en']);
MELBIS()->UnitCallbackCustom('trans', 'MELBIS_INC_translate', ['from' => 'ru']);

2. Calling in an HTML Template

In the template you specify the alias (with the $ sign) and, if needed, list additional arguments separated by commas. Arguments can be keys from the current data array, as well as static strings or numbers.

Syntax: {MAIN_VARIABLE|$alias:ARG_1,ARG_2}

Example: {PRICE|$discount:GROUP_ID,10,USD} (where PRICE and GROUP_ID are variables from the database, and 10 and USD are static text passed directly from the markup).

3. How the Data Array (Payload) for the Function is Assembled

The parser uses a hybrid data passing model. Your function receives a single array containing data in two formats simultaneously: by universal numeric indices and by string keys.

Array structure using the example {PRICE|$discount:GROUP_ID,10,USD}:

[
    // === Universal numeric indices ===
    0 => 1500,         // Index 0 ALWAYS contains the main value of the {PRICE} tag
    1 => 5,            // Value of the GROUP_ID variable (found in current data)
    2 => '10',         // Static string (since there is no key '10' in the data)
    3 => 'USD',        // Static string

    // === String keys ===
    'price' => 1500,   // Duplicate of the main value by tag name
    'group_id' => 5,
    'usd' => 'USD',
    'from' => 'ru'     // Pulled from the PHP default settings (see below)
]

(💡 Note: the parser smartly protects numeric indices — the static argument 10 will not create a string key '10', so as not to break the numbering).

🔥 Priority layering for string keys (from lowest to highest): The associative part of the array is assembled with priority layering:

  1. (Lowest) Default system parameters from PHP: The base settings specified during registration are taken. Example: ['from' => 'en', 'color' => 'black']
  2. (Medium) Main variable from the template: The parser takes the variable name before the | sign and places it in the array. Example: ['from' => 'en', 'title' => 'Value']
  3. (Highest) Additional keys from the template: If the developer explicitly passed a key (e.g., FROM) that matches a PHP default setting, the value from the HTML template completely overwrites the default.

This way, simple functions can just access $mParam[0], $mParam[1] without being tied to what the variable was called in the template, while complex functions can control business logic by overriding string keys.