Module ltml.sandbox
The LTML sandbox module returns a function environment to be used when executing templates.
Functions
returns... ([env]) |
Class Tag
Tag:__call (data) | Modifies the tag immutably. |
Tag.name | The name of the tag. |
Tag.attributes | The attributes of the tag. |
Tag.children | The tag's children. |
Class Sandbox
Sandbox:tag (name[, attributes[, children]]) | Returns a constructed tag with given attributes and children. |
Sandbox:raw (data) | Takes a raw tag and passes it into tag. |
Sandbox:def (name[, value]) | Declares an environment variable. |
Sandbox:map (list, func) | Iterates over a list of items and applies a function to all of them, returning a list of the results. |
Sandbox:cond (test[, yes[, no]]) | Returns a selection of the two final values based on the first value. |
Sandbox:isdef (var[, yes[, no]]) | A helper function which checks if the variable is defined within the environment using cond. |
Functions
- returns... ([env])
-
Parameters:
- env table A table to use as the starting environment. (optional)
Returns:
-
Sandbox
A Sandbox instance.
Class Tag
An LTML tag.
- Tag:__call (data)
-
Modifies the tag immutably.
Parameters:
- data table The attributes and children to apply to the tag.
Returns:
-
Tag
The modified tag.
- Tag.name
-
The name of the tag.
- name string
- Tag.attributes
-
The attributes of the tag.
- attributes {[string]=string,...} or {[string]=boolean,...}
- Tag.children
-
The tag's children.
- children {Tag,...}
Class Sandbox
An LTML sandbox environment.
- Sandbox:tag (name[, attributes[, children]])
-
Returns a constructed tag with given attributes and children.
Parameters:
- name string The tag's name.
- attributes table The tag's attributes. (optional)
- children table The tag's children. (optional)
Returns:
-
table
The constructed tag.
- Sandbox:raw (data)
-
Takes a raw tag and passes it into tag.
Parameters:
- data table The raw tag.
Returns:
-
table
The constructed tag.
- Sandbox:def (name[, value])
-
Declares an environment variable.
This function is optionally curried.
Parameters:
- name string A variable path name. Can be separated by dots to define variables in table structures.
- value The value to set the variable to. (optional)
- Sandbox:map (list, func)
-
Iterates over a list of items and applies a function to all of them, returning a list of the results.
Parameters:
- list table The list of items to iterate over.
- func function The function to apply.
Returns:
-
table
The list of results.
- Sandbox:cond (test[, yes[, no]])
-
Returns a selection of the two final values based on the first value.
This function is optionally curried.
Parameters:
- test boolean The boolean value to act on.
- yes The value to return when test is truthy. (optional)
- no The value to return when test is falsy. (optional)
Returns:
-
The value of yes if test is truthy, or the value of no if test is falsy.
- Sandbox:isdef (var[, yes[, no]])
-
A helper function which checks if the variable is defined within the environment using cond.
This function is optionally curried.
Parameters:
- var string The name of the variable to check for. Can be dot separated for variables within tables.
- yes The value to return when the variable is defined. (optional)
- no The value to return when the variable is not defined. (optional)
Returns:
-
The value of yes if the variable is defined, or the value of no if the variable is not defined.