2 Commits
3.0.3 ... 3.0.5

Author SHA1 Message Date
Tyler Akins
26ca5059d8 Fix slowness with larger templates
Closes #69 and #71
Released 3.0.5
2024-03-27 21:57:11 -05:00
Tyler Akins
6e57510ba9 Making it more clear that sourced files are shell
Addresses part of the concerns from #69
2023-11-16 16:04:52 -06:00
3 changed files with 27 additions and 13 deletions

View File

@@ -117,9 +117,11 @@ There are more scripts available in the [demos directory](demo/) that could help
There are additional features that the program supports. Try using `mo --help` to see what is available.
Please note that this command is written in Bash and pulls data from either the environment or (when using `--source`) from a text file that will be sourced and loaded into the environment, which means you will need to have Bash-style variables defined. Please see the examples in `demo/` for different ways you can use `mo`.
Enhancements
-----------
------------
In addition to many of the features built-in to Mustache, `mo` includes a number of unique features that make it a bit more powerful.

23
mo
View File

@@ -38,7 +38,8 @@
#/ This message.
#/ -s=FILE, --source=FILE
#/ Load FILE into the environment before processing templates.
#/ Can be used multiple times.
#/ 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
@@ -429,20 +430,30 @@ mo::indirectArray() {
#
# Returns nothing.
mo::trimUnparsed() {
local moLast moR moN moT
local moLastLen moR moN moT
moLast=""
moLastLen=0
moR=$'\r'
moN=$'\n'
moT=$'\t'
while [[ "$MO_UNPARSED" != "$moLast" ]]; do
moLast=$MO_UNPARSED
while [[ "${#MO_UNPARSED}" != "$moLastLen" ]]; do
moLastLen=${#MO_UNPARSED}
# These conditions are necessary for a significant speed increase
while [[ "${MO_UNPARSED:0:1}" == " " ]]; do
MO_UNPARSED=${MO_UNPARSED# }
done
while [[ "${MO_UNPARSED:0:1}" == "$moR" ]]; do
MO_UNPARSED=${MO_UNPARSED#"$moR"}
done
while [[ "${MO_UNPARSED:0:1}" == "$moN" ]]; do
MO_UNPARSED=${MO_UNPARSED#"$moN"}
done
while [[ "${MO_UNPARSED:0:1}" == "$moT" ]]; do
MO_UNPARSED=${MO_UNPARSED#"$moT"}
done
done
}
@@ -1949,7 +1960,7 @@ mo::tokenizeTagContentsSingleQuote() {
# Save the original command's path for usage later
MO_ORIGINAL_COMMAND="$(cd "${BASH_SOURCE[0]%/*}" || exit 1; pwd)/${BASH_SOURCE[0]##*/}"
MO_VERSION="3.0.3"
MO_VERSION="3.0.5"
# If sourced, load all functions.
# If executed, perform the actions as expected.

View File

@@ -43,7 +43,8 @@ Options:
This message.
-s=FILE, --source=FILE
Load FILE into the environment before processing templates.
Can be used multiple times.
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
@@ -93,7 +94,7 @@ This is open source! Please feel free to contribute.
https://github.com/tests-always-included/mo
MO_VERSION=3.0.3
MO_VERSION=3.0.5
EOF
}