Internal: Determine if a given environment variable exists and if it is an array.
* $1 - Name of environment variable
Examples
var=(abc)
if moIsArray var; the
echo "This is an array"
echo "Make sure you don't accidentally use $var"
fi
Returns 0 if the name is not empty, 1 otherwise.
moIsFunction()
--------------
Internal: Determine if the given name is a defined function.
* $1 - Function name to check
Examples
moo () {
echo "This is a function"
}
if moIsFunction moo; then
echo "moo is a defined function"
fi
Returns 0 if the name is a function, 1 otherwise.
moIsStandalone()
----------------
Internal: Determine if the tag is a standalone tag based on whitespace before and after the tag.
Passes back a string containing two numbers in the format "BEFORE AFTER" like "27 10". It indicates the number of bytes remaining in the "before" string (27) and the number of bytes to trim in the "after" string (10). Useful for string manipulation:
* $1 - Variable to set for passing data back
* $2 - Content before the tag
* $3 - Content after the tag
* $4 - true/false: is this the beginning of the content?
Examples
moIsStandalone RESULT "$before" "$after" false || return 0
* $1 - Variable name to receive the joined content
* $2 - Joiner
* $3-$* - Elements to join
Returns nothing.
moLoadFile()
------------
Internal: Read a file into a variable.
* $1 - Variable name to receive the file's content
* $2 - Filename to load
Returns nothing.
moLoop()
--------
Internal: Process a chunk of content some number of times. Writes output to stdout.
* $1 - Content to parse repeatedly
* $2 - Tag prefix (context name)
* $3-* - Names to insert into the parsed content
Returns nothing.
moParse()
---------
Internal: Parse a block of text, writing the result to stdout.
* $1 - Block of text to change
* $2 - Current name (the variable NAME for what {{.}} means)
* $3 - true when no content before this, false otherwise
Returns nothing.
moPartial()
-----------
Internal: Process a partial.
Indentation should be applied to the entire partial
Prefix all variables.
* $1 - Name of destination "content" variable.
* $2 - Content before the tag that was not yet written
* $3 - Tag content
* $4 - Content after the tag
* $5 - true/false: is this the beginning of the content?
* $6 - Current context name
Returns nothing.
moShow()
--------
Internal: Show an environment variable or the output of a function to stdout.
Limit/prefix any variables used.
* $1 - Name of environment variable or function
* $2 - Current context
Returns nothing.
moSplit()
---------
Internal: Split a larger string into an array.
* $1 - Destination variable
* $2 - String to split
* $3 - Starting delimiter
* $4 - Ending delimiter (optional)
Returns nothing.
moStandaloneAllowed()
---------------------
Internal: Handle the content for a standalone tag. This means removing whitespace (not newlines) before a tag and whitespace and a newline after a tag. That is, assuming, that the line is otherwise empty.
* $1 - Name of destination "content" variable.
* $2 - Content before the tag that was not yet written
* $3 - Tag content (not used)
* $4 - Content after the tag
* $5 - true/false: is this the beginning of the content?
Returns nothing.
moStandaloneDenied()
--------------------
Internal: Handle the content for a tag that is never "standalone". No adjustments are made for newlines and whitespace.
* $1 - Name of destination "content" variable.
* $2 - Content before the tag that was not yet written
* $3 - Tag content (not used)
* $4 - Content after the tag
Returns nothing.
moTest()
--------
Internal: Determines if the named thing is a function or if it is a non-empty environment variable.
Do not use variables without prefixes here if possible as this needs to check if any name exists in the environment
* $1 - Name of environment variable or function
* $2 - Current value (our context)
Returns 0 if the name is not empty, 1 otherwise.
moTrimChars()
-------------
Internal: Trim the leading whitespace only.
* $1 - Name of destination variable
* $2 - The string
* $3 - true/false - trim front?
* $4 - true/false - trim end?
* $5-* - Characters to trim
Returns nothing.
moTrimWhitespace()
------------------
Internal: Trim leading and trailing whitespace from a string.
* $1 - Name of variable to store trimmed string
* $2 - The string
Returns nothing.
moUsage()
---------
Internal: Displays the usage for mo. Pulls this from the file that contained the `mo` function. Can only work when the right filename comes is the one argument, and that only happens when `mo` is called with `$0` set to this file.