MO

MO#

Shortcut to call the mustache template engine.

Mo is a mustache template rendering software written in bash. It inserts
environment variables into templates.

Simply put, mo will change {{VARIABLE}} into the value of that
environment variable. You can use {{#VARIABLE}}content{{/VARIABLE}} to
conditionally display content or iterate over the values of an array.

Learn more about mustache templates at https://mustache.github.io/

Simple usage:

    mo [OPTIONS] filenames…

Options:

Option

Description

    –allow-function-arguments
    Permit functions to be called with additional arguments. Otherwise,
    the only way to get access to the arguments is to use the
    MO_FUNCTION_ARGS environment variable.
    -d, –debug
    Enable debug logging to stderr.
    -u, –fail-not-set
    Fail upon expansion of an unset variable. Will silently ignore by
    default. Alternately, set MO_FAIL_ON_UNSET to a non-empty value.
    -x, –fail-on-function
    Fail when a function returns a non-zero status code instead of
    silently ignoring it. Alternately, set MO_FAIL_ON_FUNCTION to a
    non-empty value.
    -f, –fail-on-file
    Fail when a file (from command-line or partial) does not exist.
    Alternately, set MO_FAIL_ON_FILE to a non-empty value.
    -e, –false
    Treat the string “false” as empty for conditionals. Alternately,
    set MO_FALSE_IS_EMPTY to a non-empty value.
    -h, –help
    This message.
    -s=FILE, –source=FILE
    Load FILE into the environment before processing templates.
    Can be used multiple times. The file must be a valid shell script
    and should only contain variable assignments.
    -o=DELIM, –open=DELIM
    Set the opening delimiter. Default is “{{“.
    -c=DELIM, –close=DELIM
    Set the closing delimiter. Default is “}}”.
    – Indicate the end of options. All arguments after this will be
    treated as filenames only. Use when filenames may start with
    hyphens.

Mo uses the following environment variables:

MO_ALLOW_FUNCTION_ARGUMENTS - When set to a non-empty value, this allows
    functions referenced in templates to receive additional options and
    arguments.
MO_CLOSE_DELIMITER - The string used when closing a tag. Defaults to “}}”.
    Used internally.
MO_CLOSE_DELIMITER_DEFAULT - The default value of MO_CLOSE_DELIMITER. Used
    when resetting the close delimiter, such as when parsing a partial.
MO_CURRENT - Variable name to use for “.”.
MO_DEBUG - When set to a non-empty value, additional debug information is
    written to stderr.
MO_FUNCTION_ARGS - Arguments passed to the function.
MO_FAIL_ON_FILE - If a filename from the command-line is missing or a
    partial does not exist, abort with an error.
MO_FAIL_ON_FUNCTION - If a function returns a non-zero status code, abort
    with an error.
MO_FAIL_ON_UNSET - When set to a non-empty value, expansion of an unset env
    variable will be aborted with an error.
MO_FALSE_IS_EMPTY - When set to a non-empty value, the string “false” will
    be treated as an empty value for the purposes of conditionals.
MO_OPEN_DELIMITER - The string used when opening a tag. Defaults to “{{“.
    Used internally.
MO_OPEN_DELIMITER_DEFAULT - The default value of MO_OPEN_DELIMITER. Used
    when resetting the open delimiter, such as when parsing a partial.
MO_ORIGINAL_COMMAND - Used to find the mo program in order to generate a
    help message.
MO_PARSED - Content that has made it through the template engine.
MO_STANDALONE_CONTENT - The unparsed content that preceded the current tag.
    When a standalone tag is encountered, this is checked to see if it only
    contains whitespace. If this and the whitespace condition after a tag is
    met, then this will be reset to $’\n’.
MO_UNPARSED - Template content yet to make it through the parser.

Mo is under a MIT style license with an additional non-advertising clause.
See LICENSE.md for the full text.

This is open source! Please feel free to contribute.

tests-always-included/mo

This is a partial rewrite supporting Bash 5+ only.
JuergenMang/mo

MO_VERSION=5.0.0