Core Concepts & Processor Architecture
AwesomeEnterprise is a custom low-code templating platform. It processes code containing comments, shortcodes, and plain text, and outputs a single text stream.
The Execution Lifecycle
When a block of code is parsed by the Awesome Processor, it executes in three steps:
- Comment Removal: All comments (
//* ... *//) are stripped out.
- First-Level Shortcode Execution: Every first-level shortcode is evaluated, resolved, and replaced with its text output. If a shortcode returns an array or object directly, the processor outputs its PHP
print_r textual representation. Thus, you must explicitly format arrays/objects or use Outputters.
- Stream Output: The parsed text with evaluated shortcodes is returned.
Shortcode Execution Order
Every shortcode executes in four distinct processor stages:
- Conditions Processor (
c.*, and.*, or.*): Evaluates conditional attributes. If they resolve to false, the shortcode is skipped entirely.
- Service Processor: Runs the core service using the provided service attributes and inner content. Returns a result value of any data type.
- Modifiers Processor (
m.*, m2.*): Sequentially modifies the value returned by the service processor.
- Outputters Processor (
o.*, o2.*): Directs the final modified value (e.g., sets an env variable, dumps output, or deletes the value to return an empty string). If no outputter is present, the modified value is printed directly to the output stream.
Syntax & Datatypes
Comments
Comments use //* to start and *// to end. They can be single-line or multi-line:
//* This is a single-line comment *//
//*
This is a
multiline comment
*//
Shortcode Structure
Shortcodes can be self-closing:
[str.create "Vikas Kumar" /]
Or they can wrap inner content (enclosed between opening and closing tags):
[if.equal lhs="6" rhs="6"]
we are equal
[/if.equal]
Datatype Castings
By default, all shortcode attribute values are treated as strings. To enforce specific datatypes, use typecast prefixes in service attributes:
int:<value>: Casts value to an integer (e.g. int:42).
num:<value> or float:<value>: Casts value to a float (e.g. num:22.99).
str:<value>: Casts value to a string (e.g. str:hello).
bool:<value>: Converts "false" to false, else casts to bool (e.g. bool:false).
comma:<val1,val2>: Converts a comma-separated list into a string array (e.g. comma:a,b,c).
get:<path>: Retrieves the value at the given environment path and preserves its original datatype.
x:<service_call>: Executes a service and returns the output with its datatype preserved (e.g., x:request2.get name).
Variables & Service References in Attributes
- Curly Braces
{path.key}: Evaluates the environment variable path and inserts its value. Nested curly braces are not allowed (e.g., {person.{name}} is invalid). Spaces are not allowed inside curly braces.
- Double Curly Braces
{{service.name}}: Executes the specified service call and returns the result value. It is recommended to wrap double curly braces in double quotes (e.g., "{{request2.get name}}").
- Important: Curly braces
{} and {{}} are only parsed within attributes, not inside the content of shortcodes. To print variables or execute code inside content, write full shortcodes (e.g. [env.get path /]).
Variable Scoping Scenarios
To prevent cluttering the global scope, AwesomeEnterprise supports three scopes:
1. Module Scope (module.*)
Active when a module is running. It stores module state and parameters inside a temporary module state variable in the environment.
- Parameters passed to a module (
[collection.module param1=val /]) are automatically attached to the module state variable.
- Services like
[module.get], [module.set], and [module.set_array] read and write to this local scope.
- Use
[module.return <env_path> /] to exit the module early and return the value at <env_path>.
2. Template Scope (template.*)
Active when a template runs within a module. It stores local parameters passed directly to the template.
- Use
[template.get], [template.set], and [template.set_array] to manage template variables.
- Use
[template.return <env_path> /] to exit early and return the value at <env_path>.
3. Block Scope (do.*)
Active inside a [do.@local_var] block. The local variable @local_var is destroyed immediately when the closing [/do.@local_var] is reached.
[do.@temp]
[env.set @temp.x="Hello World" /]
[env.get @temp.x /]
[/do.@temp]
//* At this point, @temp.x no longer exists *//
Core API Library Reference
Env Library
Used to interact with the environment state.
[env.set key=val /]: Sets one or more variables in the environment.
[env.get path /]: Returns the value at path.
[env.set_raw path]content[/env.set_raw]: Saves raw, unparsed content at path to be evaluated later.
[env.set_array path]...[/env.set_array]: Builds nested multidimensional associative or indexed arrays.
[env.dump path /]: Calls PHP var_dump on the value at path.
[env.echo path /]: Prints the value at path using PHP echo.
Loop Library
Allows range-based or array-based iterations.
- Array Loop:
[loop.@iterator array_path] ... [/loop.@iterator]
Exposes these variables inside the loop:
[env.@iterator.item]: The current item value. If the array contains objects, nested properties of the current item must be accessed by prefixing them with .item (e.g. [env.@iterator.item.property /] or inside attributes as {@iterator.item.property}).
- CRITICAL RULE: Never access properties directly on the iterator itself (e.g.,
{@iterator.property} or [env.@iterator.property /] is invalid and will fail). You must go through .item (e.g., {@iterator.item.property}).
[env.@iterator.key]: The current key.
[env.@iterator.index]: 1-based index.
[env.@iterator.counter]: 0-based index.
[env.@iterator.first], [env.@iterator.last], [env.@iterator.between]: Boolean flags.
[env.@iterator.odd], [env.@iterator.even]: Boolean flags.
- Range Loop:
[loop.@iterator start="1" stop="5" step="1"] ... [/loop.@iterator]
Exposes the same metadata fields. If start < stop, increments by step; if stop < start, decrements.
If Library
Handles conditional checks and branching.
[if.equal lhs=A rhs=B] ... [/if.equal]: Checks if lhs equals rhs.
[if.not_equal lhs=A rhs=B] ... [/if.not_equal]: Checks if lhs does not equal rhs.
[if.else] ... [/if.else]: Executes if the preceding if condition fails.
[if.arr path]: True if the variable at path is an array.
[if.contains needle=val haystack={array_val}]: True if needle is in the haystack array.
[if.not_contains needle=val haystack={array_val}]: True if needle is not in the haystack array.
[if.empty path], [if.not_empty path]: Checks if string or array is empty/not empty.
[if.int path], [if.num path], [if.not_int path], [if.not_num path]: Type checking.
Math Library
Performs mathematical calculations.
[math.solve "expression" /]: Evaluates math expressions. Power operation uses ** (e.g., 2**8 for $2^8$). Evaluates literals, not env paths directly.
[math.minus_one "val" /]: Decrements value by 1.
[math.plus_one "val" /]: Increments value by 1.
Str, Int, Bool, Num, and Date Libraries
[str.get path default=val /], [str.create "val" /]: Gets or creates string values.
[int.get path default=0 /], [int.create 42 /]: Gets or creates integers.
[bool.get path default=false /], [bool.create "true" /]: Gets or creates booleans.
[num.get path default=0.0 /], [num.create "2.00" /]: Gets or creates floats.
[date.get path default=val /], [date.create "2026-05-20" /]: Gets or creates DateTime objects.
[date.modify date=date_val frequency="+1 day" /]: Modifies date.
[date.diff date_from=A date_to=B type="days" /]: Calculates date difference (mins, hours, days, years, or english).
Arr Library
[arr.set path key1=val1 /]: Sets array keys.
[arr.create] ... [/arr.create]: Builds array from content.
[arr.empty o.set=path /]: Returns an empty array.
[arr.search_deep main=array_path search=value field=field_name /]: Recursively searches deep arrays/objects.
Request2 Library
Safely reads input from PHP $_REQUEST, filtering for XSS.
[request2.get "key" /]: Cleans and returns the value of "key" from request.
- If
key is "request_body", returns raw request body (php://input).
- If
key is "post_json", returns sanitised JSON string of $_POST.
[request2.<key> /]: Shorthand syntax for [request2.get "<key>" /].
Curl Library
Used for executing HTTP requests. Returns an array with keys info, headers, cookies, and result.
[curl.api.get url=... data=... header=... proxy=... /]
[curl.api.post url=... data=... header=... proxy=... /]
[curl.page.get url=... data=... header=... proxy=... /]
[curl.api.patch url=... data=... header=... proxy=... /]
Mysqli Library (Single Query)
[mysqli.cud]query[/mysqli.cud]: Fires an INSERT, UPDATE, or DELETE query.
[mysqli.fetch.rows]query[/mysqli.fetch.rows]: Returns multiple rows in a rows array.
[mysqli.fetch.row]query[/mysqli.fetch.row]: Returns exactly 0 or 1 row.
[mysqli.fetch.exactly_one_row]query[/mysqli.fetch.exactly_one_row]: Returns exactly 1 row. Throws an error otherwise.
[mysqli.fetch.col]query[/mysqli.fetch.col]: Returns a single column as an array.
[mysqli.fetch.scalar]query[/mysqli.fetch.scalar]: Returns exactly 1 row and 1 column value.
[mysqli.fetch.count]query[/mysqli.fetch.count]: Returns a numeric count.
Mysqli.multi Library (Multi Queries & Transactions)
Used to fire multiple queries in a single call.
[mysqli.multi.cud]...[/mysqli.multi.cud]: Executes multi-statement CUD queries.
[mysqli.multi.fetch.rows]...[/mysqli.multi.fetch.rows]: Executes multi-statements and returns the last resultset.
[mysqli.transaction.commit]...[/mysqli.transaction.commit]: Runs queries in an isolated SQL transaction, automatically committing them.
[mysqli.transaction.rollback]...[/mysqli.transaction.rollback]: Runs queries and rolls back at the end.
Security & Database Escaping
To prevent SQL Injection and XSS attacks, never concatenate raw values directly into SQL query strings. Instead:
- Escape all variables using the
esc library.
- Set them as MySQL variables at the beginning of a multi-query.
- Reference the MySQL variables inside the SQL statements.
Esc Library Reference (MySQL queries only)
All esc services receive an environment variable path (not a literal value) as their main attribute.
[esc.int path /]: Casts path value to safe integer.
[esc.num path /]: Casts path value to safe float.
[esc.table path /]: Escapes table name string.
[esc.str path /]: Escapes string value and wraps it in single quotes.
[esc.id path /]: Sanitises typical IDs (e.g. B89), wrapping the result in single quotes.
[esc.date path /]: Converts date to YYYYMMDD and returns DATE('escaped_date').
[esc.like path /]: Escapes LIKE query wildcards (% and _). Does not add single quotes.
[esc.unsafe path /]: Converts numeric array to a comma-separated string (e.g., 54,45,67).
[esc.unsafe.quotes path /]: Converts string array to comma-separated single-quoted escaped strings (e.g. 'hello','world').
[esc.safe path /], [esc.safe.quotes path /]: Acts as a wrapper indicating values are already escaped.
Safe SQL Query Pattern
[mysqli.multi.fetch.rows o.set="template.results"]
SET @category = [esc.str request.category /];
SET @status = 'publish';
SELECT ID, post_title
FROM wp_posts
WHERE post_status = @status AND post_name = @category;
[/mysqli.multi.fetch.rows]
Note: MySQL does not allow MySQL variables inside the LIMIT clause. Limit values must be hardcoded in the query string itself.
Modifiers, Conditions & Outputters (Cheat Sheet)
Modifiers (m.*)
m.run=yes: Executes unparsed code stored in a string variable.
m.lower=yes, m.upper=yes, m.capitalize=yes, m.sentence=yes: Case conversions.
m.trim=yes, m.ltrim=yes, m.rtrim=yes: Trims whitespaces.
m.left=i:N, m.right=i:N: Truncates characters from left or right.
m.substr=yes m.start=i:X m.chars=i:Y: Extracts substring.
m.length=yes: String length or array count.
m.json_encode=yes, m.json_decode=yes: JSON conversions.
m.explode_on=s:comma/space/dot/<delim>: Explodes string into array.
m.implode_on=s:comma/space/dot/quote_comma/<delim>: Implodes array into string.
m.number_format=yes m.decimals=n:X: Formats a number with decimals.
m.money_format='en_IN' m.currency='INR': Currency formatting.
m.date_format='M d, Y': Formats date strings.
m.hhmm_format=yes: Formats seconds into HH:MM:SS.
m.words=n:X / m.words=yes: Limits words in string.
m.url_encode=yes, m.url_decode=yes: URL encoding/decoding.
m.arr_item=s:first/last/key or m.arr_item=n:index: Extracts array item.
m.unset_item=first/last/key: Removes array item.
m.shuffle=yes: Shuffles array items.
m.solve=yes: Evaluates string as mathematical expression.
m.to_str=yes, m.to_int=yes, m.to_num=yes, m.to_bool=yes: Type conversion.
m.append='str', m.prepend='str': Appends/prepends strings.
m.empty_array=yes: Clears array.
m.sort='asort/arsort/ksort/rsort': Sorts array.
Conditions (c.*)
c.ignore=yes: Always skips shortcode.
c.odd=i:N, c.even=i:N: Checks parity of number.
c.cond=A c.eq=B: True if A === B.
c.cond=A c.neq=B: True if A !== B.
c.cond=A c.gt=B, c.cond=A c.lt=B, c.cond=A c.gte=B, c.cond=A c.lte=B: Comparison filters.
c.true=b:val, c.false=b:val: Boolean validations.
c.yes=val, c.no=val: Checks if value is the string "yes" or "no".
c.arr=path, c.not_arr=path: Checks array status.
c.empty=path, c.not_empty=path: Empty validations.
c.null=path, c.not_null=path: Null validations.
c.contains=needle c.haystack={arr}: Checks array content.
c.exists=key, c.not_exists=key: Checks environment paths.
c.logged_in=yes, c.not_logged_in=yes: User session state.
c.user_can=role, c.user_cannot=role: User role permissions.
c.device='mobile,tablet': Matches request user device.
Outputters (o.*)
o.die=yes: Outputs value and calls PHP die().
o.echo=yes: Echoes value to standard output stream (retains value for subsequent processors).
o.dump=yes: Prints HTML representation of the value (retains value).
o.console=yes: Logs output in browser console (retains value).
o.log=yes: Logs output in error logs (retains value).
o.destroy=yes: Destroys the value and returns empty string.
o.set='path': Saves the value at the env path and returns empty string.
o.merge_with='path': Merges array value with target array at env path.
Common Pitfalls & Rules
- Single Quotes in Unnamed Attributes: Do not use single quotes to wrap values inside unnamed/main attributes. Use double quotes or no quotes instead.
- Invalid:
[str.create 'hello' /]
- Valid:
[str.create "hello" /] or [str.create hello /]
- Shortcodes Inside Attributes: Do not nest square brackets inside shortcode attributes. Use curly braces to fetch variables.
- Invalid:
[env.set x=[env.get y] /]
- Valid:
[env.set x={y} /]
- Untrapped Output Streams: Shortcodes that return data (e.g.,
mysqli.fetch.rows or curl.api.get) will print their text/PHP debug outputs directly to the page unless trapped with o.set or deleted with o.destroy.
- Invalid:
[mysqli.fetch.rows]SELECT * FROM wp_posts[/mysqli.fetch.rows] (dumps array output to page)
- Valid:
[mysqli.fetch.rows o.set="template.posts"]SELECT * FROM wp_posts[/mysqli.fetch.rows]
- Shortcode-in-Shortcode Syntax Error: Nested square brackets in service attributes will fail to parse.
- Invalid:
[env.set x=[esc.str y] /]
- Valid:
[esc.str y o.set="temp.esc_y" /][env.set x={temp.esc_y} /]
- Nested Curly Braces: Variable syntax
{} cannot contain other curly braces.
- Invalid:
{person.{name_field}}
- Valid: Find the nested value outside first, set it to a flat variable, then reference that flat variable.
- Curly Braces in Content:
{} and {{}} are not evaluated within inner shortcode content; they will print literally. Use appropriate shortcodes (e.g., [env.get ...]) in content areas.
- Limit Variables in MySQL: Do not pass MySQL variables (e.g.,
@limit) into the LIMIT clause of SQL queries. Use hardcoded limit numbers in the query template.
- Strict Service Guidelines: Never use functions or services not explicitly documented in the framework guidelines.
- Loop Variable Access (Strict Scoping): When iterating with
[loop.@iterator array_path], the properties of the current item are scoped under the .item namespace.
- Invalid (Direct property access):
{@iterator.name} or [env.@iterator.name /]
- Valid (Correct scoped access):
{@iterator.item.name} or [env.@iterator.item.name /]
1---2name: awesome-enterprise-shortcodes3description: Programming guidelines and service reference for developing in the AwesomeEnterprise low-code framework using shortcodes.4---56## Core Concepts & Processor Architecture78AwesomeEnterprise is a custom low-code templating platform. It processes code containing comments, shortcodes, and plain text, and outputs a single text stream.910### The Execution Lifecycle11When a block of code is parsed by the Awesome Processor, it executes in three steps:121. **Comment Removal**: All comments (`//* ... *//`) are stripped out.132. **First-Level Shortcode Execution**: Every first-level shortcode is evaluated, resolved, and replaced with its text output. If a shortcode returns an array or object directly, the processor outputs its PHP `print_r` textual representation. Thus, you must explicitly format arrays/objects or use Outputters.143. **Stream Output**: The parsed text with evaluated shortcodes is returned.1516### Shortcode Execution Order17Every shortcode executes in four distinct processor stages:181. **Conditions Processor (`c.*`, `and.*`, `or.*`)**: Evaluates conditional attributes. If they resolve to `false`, the shortcode is skipped entirely.192. **Service Processor**: Runs the core service using the provided service attributes and inner content. Returns a result value of any data type.203. **Modifiers Processor (`m.*`, `m2.*`)**: Sequentially modifies the value returned by the service processor.214. **Outputters Processor (`o.*`, `o2.*`)**: Directs the final modified value (e.g., sets an env variable, dumps output, or deletes the value to return an empty string). If no outputter is present, the modified value is printed directly to the output stream.2223---2425## Syntax & Datatypes2627### Comments28Comments use `//*` to start and `*//` to end. They can be single-line or multi-line:29```30//* This is a single-line comment *//3132//*33This is a34multiline comment35*//36```3738### Shortcode Structure39Shortcodes can be self-closing:40```41[str.create "Vikas Kumar" /]42```43Or they can wrap inner content (enclosed between opening and closing tags):44```45[if.equal lhs="6" rhs="6"]46 we are equal47[/if.equal]48```4950### Datatype Castings51By default, all shortcode attribute values are treated as strings. To enforce specific datatypes, use typecast prefixes in service attributes:52* `int:<value>`: Casts value to an integer (e.g. `int:42`).53* `num:<value>` or `float:<value>`: Casts value to a float (e.g. `num:22.99`).54* `str:<value>`: Casts value to a string (e.g. `str:hello`).55* `bool:<value>`: Converts `"false"` to `false`, else casts to `bool` (e.g. `bool:false`).56* `comma:<val1,val2>`: Converts a comma-separated list into a string array (e.g. `comma:a,b,c`).57* `get:<path>`: Retrieves the value at the given environment path and preserves its original datatype.58* `x:<service_call>`: Executes a service and returns the output with its datatype preserved (e.g., `x:request2.get name`).5960### Variables & Service References in Attributes61* **Curly Braces `{path.key}`**: Evaluates the environment variable path and inserts its value. Nested curly braces are not allowed (e.g., `{person.{name}}` is invalid). Spaces are not allowed inside curly braces.62* **Double Curly Braces `{{service.name}}`**: Executes the specified service call and returns the result value. It is recommended to wrap double curly braces in double quotes (e.g., `"{{request2.get name}}"`).63* **Important**: Curly braces `{}` and `{{}}` are **only parsed within attributes**, not inside the content of shortcodes. To print variables or execute code inside content, write full shortcodes (e.g. `[env.get path /]`).6465---6667## Variable Scoping Scenarios6869To prevent cluttering the global scope, AwesomeEnterprise supports three scopes:7071### 1. Module Scope (`module.*`)72Active when a module is running. It stores module state and parameters inside a temporary `module` state variable in the environment.73* Parameters passed to a module (`[collection.module param1=val /]`) are automatically attached to the `module` state variable.74* Services like `[module.get]`, `[module.set]`, and `[module.set_array]` read and write to this local scope.75* Use `[module.return <env_path> /]` to exit the module early and return the value at `<env_path>`.7677### 2. Template Scope (`template.*`)78Active when a template runs within a module. It stores local parameters passed directly to the template.79* Use `[template.get]`, `[template.set]`, and `[template.set_array]` to manage template variables.80* Use `[template.return <env_path> /]` to exit early and return the value at `<env_path>`.8182### 3. Block Scope (`do.*`)83Active inside a `[do.@local_var]` block. The local variable `@local_var` is destroyed immediately when the closing `[/do.@local_var]` is reached.84```85[do.@temp]86 [env.set @temp.x="Hello World" /]87 [env.get @temp.x /]88[/do.@temp]89//* At this point, @temp.x no longer exists *//90```9192---9394## Core API Library Reference9596### Env Library97Used to interact with the environment state.98* `[env.set key=val /]`: Sets one or more variables in the environment.99* `[env.get path /]`: Returns the value at `path`.100* `[env.set_raw path]content[/env.set_raw]`: Saves raw, unparsed content at `path` to be evaluated later.101* `[env.set_array path]...[/env.set_array]`: Builds nested multidimensional associative or indexed arrays.102* `[env.dump path /]`: Calls PHP `var_dump` on the value at `path`.103* `[env.echo path /]`: Prints the value at `path` using PHP `echo`.104105### Loop Library106Allows range-based or array-based iterations.107* **Array Loop**: `[loop.@iterator array_path] ... [/loop.@iterator]`108 Exposes these variables inside the loop:109 * `[env.@iterator.item]`: The current item value. If the array contains objects, nested properties of the current item **must** be accessed by prefixing them with `.item` (e.g. `[env.@iterator.item.property /]` or inside attributes as `{@iterator.item.property}`).110 * **CRITICAL RULE**: Never access properties directly on the iterator itself (e.g., `{@iterator.property}` or `[env.@iterator.property /]` is **invalid** and will fail). You must go through `.item` (e.g., `{@iterator.item.property}`).111 * `[env.@iterator.key]`: The current key.112 * `[env.@iterator.index]`: 1-based index.113 * `[env.@iterator.counter]`: 0-based index.114 * `[env.@iterator.first]`, `[env.@iterator.last]`, `[env.@iterator.between]`: Boolean flags.115 * `[env.@iterator.odd]`, `[env.@iterator.even]`: Boolean flags.116* **Range Loop**: `[loop.@iterator start="1" stop="5" step="1"] ... [/loop.@iterator]`117 Exposes the same metadata fields. If `start` < `stop`, increments by `step`; if `stop` < `start`, decrements.118119### If Library120Handles conditional checks and branching.121* `[if.equal lhs=A rhs=B] ... [/if.equal]`: Checks if `lhs` equals `rhs`.122* `[if.not_equal lhs=A rhs=B] ... [/if.not_equal]`: Checks if `lhs` does not equal `rhs`.123* `[if.else] ... [/if.else]`: Executes if the preceding `if` condition fails.124* `[if.arr path]`: True if the variable at `path` is an array.125* `[if.contains needle=val haystack={array_val}]`: True if `needle` is in the `haystack` array.126* `[if.not_contains needle=val haystack={array_val}]`: True if `needle` is not in the `haystack` array.127* `[if.empty path]`, `[if.not_empty path]`: Checks if string or array is empty/not empty.128* `[if.int path]`, `[if.num path]`, `[if.not_int path]`, `[if.not_num path]`: Type checking.129130### Math Library131Performs mathematical calculations.132* `[math.solve "expression" /]`: Evaluates math expressions. Power operation uses `**` (e.g., `2**8` for $2^8$). Evaluates literals, not env paths directly.133* `[math.minus_one "val" /]`: Decrements value by 1.134* `[math.plus_one "val" /]`: Increments value by 1.135136### Str, Int, Bool, Num, and Date Libraries137* `[str.get path default=val /]`, `[str.create "val" /]`: Gets or creates string values.138* `[int.get path default=0 /]`, `[int.create 42 /]`: Gets or creates integers.139* `[bool.get path default=false /]`, `[bool.create "true" /]`: Gets or creates booleans.140* `[num.get path default=0.0 /]`, `[num.create "2.00" /]`: Gets or creates floats.141* `[date.get path default=val /]`, `[date.create "2026-05-20" /]`: Gets or creates DateTime objects.142* `[date.modify date=date_val frequency="+1 day" /]`: Modifies date.143* `[date.diff date_from=A date_to=B type="days" /]`: Calculates date difference (`mins`, `hours`, `days`, `years`, or `english`).144145### Arr Library146* `[arr.set path key1=val1 /]`: Sets array keys.147* `[arr.create] ... [/arr.create]`: Builds array from content.148* `[arr.empty o.set=path /]`: Returns an empty array.149* `[arr.search_deep main=array_path search=value field=field_name /]`: Recursively searches deep arrays/objects.150151### Request2 Library152Safely reads input from PHP `$_REQUEST`, filtering for XSS.153* `[request2.get "key" /]`: Cleans and returns the value of "key" from request.154 * If `key` is `"request_body"`, returns raw request body (`php://input`).155 * If `key` is `"post_json"`, returns sanitised JSON string of `$_POST`.156* `[request2.<key> /]`: Shorthand syntax for `[request2.get "<key>" /]`.157158### Curl Library159Used for executing HTTP requests. Returns an array with keys `info`, `headers`, `cookies`, and `result`.160* `[curl.api.get url=... data=... header=... proxy=... /]`161* `[curl.api.post url=... data=... header=... proxy=... /]`162* `[curl.page.get url=... data=... header=... proxy=... /]`163* `[curl.api.patch url=... data=... header=... proxy=... /]`164165### Mysqli Library (Single Query)166* `[mysqli.cud]query[/mysqli.cud]`: Fires an INSERT, UPDATE, or DELETE query.167* `[mysqli.fetch.rows]query[/mysqli.fetch.rows]`: Returns multiple rows in a `rows` array.168* `[mysqli.fetch.row]query[/mysqli.fetch.row]`: Returns exactly 0 or 1 row.169* `[mysqli.fetch.exactly_one_row]query[/mysqli.fetch.exactly_one_row]`: Returns exactly 1 row. Throws an error otherwise.170* `[mysqli.fetch.col]query[/mysqli.fetch.col]`: Returns a single column as an array.171* `[mysqli.fetch.scalar]query[/mysqli.fetch.scalar]`: Returns exactly 1 row and 1 column value.172* `[mysqli.fetch.count]query[/mysqli.fetch.count]`: Returns a numeric count.173174### Mysqli.multi Library (Multi Queries & Transactions)175Used to fire multiple queries in a single call.176* `[mysqli.multi.cud]...[/mysqli.multi.cud]`: Executes multi-statement CUD queries.177* `[mysqli.multi.fetch.rows]...[/mysqli.multi.fetch.rows]`: Executes multi-statements and returns the last resultset.178* `[mysqli.transaction.commit]...[/mysqli.transaction.commit]`: Runs queries in an isolated SQL transaction, automatically committing them.179* `[mysqli.transaction.rollback]...[/mysqli.transaction.rollback]`: Runs queries and rolls back at the end.180181---182183## Security & Database Escaping184185To prevent SQL Injection and XSS attacks, **never concatenate raw values directly into SQL query strings**. Instead:1861. Escape all variables using the `esc` library.1872. Set them as MySQL variables at the beginning of a multi-query.1883. Reference the MySQL variables inside the SQL statements.189190### Esc Library Reference (MySQL queries only)191All `esc` services receive an **environment variable path** (not a literal value) as their main attribute.192* `[esc.int path /]`: Casts path value to safe integer.193* `[esc.num path /]`: Casts path value to safe float.194* `[esc.table path /]`: Escapes table name string.195* `[esc.str path /]`: Escapes string value and wraps it in single quotes.196* `[esc.id path /]`: Sanitises typical IDs (e.g. `B89`), wrapping the result in single quotes.197* `[esc.date path /]`: Converts date to YYYYMMDD and returns `DATE('escaped_date')`.198* `[esc.like path /]`: Escapes LIKE query wildcards (`%` and `_`). Does not add single quotes.199* `[esc.unsafe path /]`: Converts numeric array to a comma-separated string (e.g., `54,45,67`).200* `[esc.unsafe.quotes path /]`: Converts string array to comma-separated single-quoted escaped strings (e.g. `'hello','world'`).201* `[esc.safe path /]`, `[esc.safe.quotes path /]`: Acts as a wrapper indicating values are already escaped.202203### Safe SQL Query Pattern204```sql205[mysqli.multi.fetch.rows o.set="template.results"]206 SET @category = [esc.str request.category /];207 SET @status = 'publish';208209 SELECT ID, post_title 210 FROM wp_posts 211 WHERE post_status = @status AND post_name = @category;212[/mysqli.multi.fetch.rows]213```214215*Note: MySQL does not allow MySQL variables inside the `LIMIT` clause. Limit values must be hardcoded in the query string itself.*216217---218219## Modifiers, Conditions & Outputters (Cheat Sheet)220221### Modifiers (`m.*`)222* `m.run=yes`: Executes unparsed code stored in a string variable.223* `m.lower=yes`, `m.upper=yes`, `m.capitalize=yes`, `m.sentence=yes`: Case conversions.224* `m.trim=yes`, `m.ltrim=yes`, `m.rtrim=yes`: Trims whitespaces.225* `m.left=i:N`, `m.right=i:N`: Truncates characters from left or right.226* `m.substr=yes m.start=i:X m.chars=i:Y`: Extracts substring.227* `m.length=yes`: String length or array count.228* `m.json_encode=yes`, `m.json_decode=yes`: JSON conversions.229* `m.explode_on=s:comma/space/dot/<delim>`: Explodes string into array.230* `m.implode_on=s:comma/space/dot/quote_comma/<delim>`: Implodes array into string.231* `m.number_format=yes m.decimals=n:X`: Formats a number with decimals.232* `m.money_format='en_IN' m.currency='INR'`: Currency formatting.233* `m.date_format='M d, Y'`: Formats date strings.234* `m.hhmm_format=yes`: Formats seconds into HH:MM:SS.235* `m.words=n:X` / `m.words=yes`: Limits words in string.236* `m.url_encode=yes`, `m.url_decode=yes`: URL encoding/decoding.237* `m.arr_item=s:first/last/key` or `m.arr_item=n:index`: Extracts array item.238* `m.unset_item=first/last/key`: Removes array item.239* `m.shuffle=yes`: Shuffles array items.240* `m.solve=yes`: Evaluates string as mathematical expression.241* `m.to_str=yes`, `m.to_int=yes`, `m.to_num=yes`, `m.to_bool=yes`: Type conversion.242* `m.append='str'`, `m.prepend='str'`: Appends/prepends strings.243* `m.empty_array=yes`: Clears array.244* `m.sort='asort/arsort/ksort/rsort'`: Sorts array.245246### Conditions (`c.*`)247* `c.ignore=yes`: Always skips shortcode.248* `c.odd=i:N`, `c.even=i:N`: Checks parity of number.249* `c.cond=A c.eq=B`: True if A === B.250* `c.cond=A c.neq=B`: True if A !== B.251* `c.cond=A c.gt=B`, `c.cond=A c.lt=B`, `c.cond=A c.gte=B`, `c.cond=A c.lte=B`: Comparison filters.252* `c.true=b:val`, `c.false=b:val`: Boolean validations.253* `c.yes=val`, `c.no=val`: Checks if value is the string `"yes"` or `"no"`.254* `c.arr=path`, `c.not_arr=path`: Checks array status.255* `c.empty=path`, `c.not_empty=path`: Empty validations.256* `c.null=path`, `c.not_null=path`: Null validations.257* `c.contains=needle c.haystack={arr}`: Checks array content.258* `c.exists=key`, `c.not_exists=key`: Checks environment paths.259* `c.logged_in=yes`, `c.not_logged_in=yes`: User session state.260* `c.user_can=role`, `c.user_cannot=role`: User role permissions.261* `c.device='mobile,tablet'`: Matches request user device.262263### Outputters (`o.*`)264* `o.die=yes`: Outputs value and calls PHP `die()`.265* `o.echo=yes`: Echoes value to standard output stream (retains value for subsequent processors).266* `o.dump=yes`: Prints HTML representation of the value (retains value).267* `o.console=yes`: Logs output in browser console (retains value).268* `o.log=yes`: Logs output in error logs (retains value).269* `o.destroy=yes`: Destroys the value and returns empty string.270* `o.set='path'`: Saves the value at the env path and returns empty string.271* `o.merge_with='path'`: Merges array value with target array at env path.272273---274275## Common Pitfalls & Rules2762771. **Single Quotes in Unnamed Attributes**: Do not use single quotes to wrap values inside unnamed/main attributes. Use double quotes or no quotes instead.278 * *Invalid*: `[str.create 'hello' /]`279 * *Valid*: `[str.create "hello" /]` or `[str.create hello /]`2802. **Shortcodes Inside Attributes**: Do not nest square brackets inside shortcode attributes. Use curly braces to fetch variables.281 * *Invalid*: `[env.set x=[env.get y] /]`282 * *Valid*: `[env.set x={y} /]`2833. **Untrapped Output Streams**: Shortcodes that return data (e.g., `mysqli.fetch.rows` or `curl.api.get`) will print their text/PHP debug outputs directly to the page unless trapped with `o.set` or deleted with `o.destroy`.284 * *Invalid*: `[mysqli.fetch.rows]SELECT * FROM wp_posts[/mysqli.fetch.rows]` (dumps array output to page)285 * *Valid*: `[mysqli.fetch.rows o.set="template.posts"]SELECT * FROM wp_posts[/mysqli.fetch.rows]`2864. **Shortcode-in-Shortcode Syntax Error**: Nested square brackets in service attributes will fail to parse.287 * *Invalid*: `[env.set x=[esc.str y] /]`288 * *Valid*: `[esc.str y o.set="temp.esc_y" /][env.set x={temp.esc_y} /]`2895. **Nested Curly Braces**: Variable syntax `{}` cannot contain other curly braces.290 * *Invalid*: `{person.{name_field}}`291 * *Valid*: Find the nested value outside first, set it to a flat variable, then reference that flat variable.2926. **Curly Braces in Content**: `{}` and `{{}}` are not evaluated within inner shortcode content; they will print literally. Use appropriate shortcodes (e.g., `[env.get ...]`) in content areas.2937. **Limit Variables in MySQL**: Do not pass MySQL variables (e.g., `@limit`) into the `LIMIT` clause of SQL queries. Use hardcoded limit numbers in the query template.2948. **Strict Service Guidelines**: Never use functions or services not explicitly documented in the framework guidelines.2959. **Loop Variable Access (Strict Scoping)**: When iterating with `[loop.@iterator array_path]`, the properties of the current item are scoped under the `.item` namespace.296 * *Invalid (Direct property access)*: `{@iterator.name}` or `[env.@iterator.name /]`297 * *Valid (Correct scoped access)*: `{@iterator.item.name}` or `[env.@iterator.item.name /]`298