Module moonwalk.util

Text processing utilities.

Functions

dump (...) Print anything, including nested tables.
trim_path (path) Trim leading and trailing slashes from a path.
normalize_path (path) Make path have exactly one leading and one trailing slash.
json_encode (data) Encode JSON.
json_decode (text) Decode JSON.
uri_encode (text) Encode URI component.
uri_decode (text) Decode URI component.
query_encode (data) Encode a table as a query string.
query_decode (text) Decode a query string into a table.


Functions

dump (...)
Print anything, including nested tables.

May be used for debugging. This dumps things to stdout, so it's not appropriate for environments like CGI. See Lua Table Serialization.

Parameters:

  • ... Anything
trim_path (path)
Trim leading and trailing slashes from a path.

Parameters:

  • path Path

Returns:

    Trimmed path

See also:

normalize_path (path)
Make path have exactly one leading and one trailing slash.

Parameters:

  • path Path

Returns:

    Normalized path

See also:

json_encode (data)
Encode JSON.

Parameters:

  • data Lua value to encode

Returns:

    JSON string

See also:

json_decode (text)
Decode JSON.

Parameters:

  • text JSON string

Returns:

    mixed

See also:

uri_encode (text)
Encode URI component.

See HTML Forms and RFC 1738.

Parameters:

  • text Plain text string

Returns:

    URI-encoded text

See also:

uri_decode (text)
Decode URI component.

Parameters:

  • text URI-encoded text

Returns:

    Plain text string

See also:

query_encode (data)
Encode a table as a query string.

This function is not used by Moonwalk, it is provided for the API author's convenience.

Parameters:

  • data Table of key-value pairs

Returns:

    Plain text string

See also:

query_decode (text)
Decode a query string into a table.

Parameters:

  • text Query string

Returns:

    Table of query params

See also:

generated by LDoc 1.4.0