diff --git a/mo b/mo index c7da112..3e8b7bf 100755 --- a/mo +++ b/mo @@ -111,7 +111,7 @@ mustache-find-string() { # $2: Context name # $3: Desired variable name mustache-full-tag-name() { - if [[ -z "$2" ]]; then + if [[ -z "$2" ]] || [[ "$2" == *.* ]]; then local "$1" && mustache-indirect "$1" "$3" else local "$1" && mustache-indirect "$1" "${2}.${3}" diff --git a/tests/globals-in-loop.env b/tests/globals-in-loop.env new file mode 100644 index 0000000..47d1b68 --- /dev/null +++ b/tests/globals-in-loop.env @@ -0,0 +1,2 @@ +STR=abc +DATA=(111 222) diff --git a/tests/globals-in-loop.expected b/tests/globals-in-loop.expected new file mode 100644 index 0000000..fe24ce5 --- /dev/null +++ b/tests/globals-in-loop.expected @@ -0,0 +1,6 @@ +Issue #7 +abc + Item: 111 + String: abc + Item: 222 + String: abc diff --git a/tests/globals-in-loop.template b/tests/globals-in-loop.template new file mode 100644 index 0000000..586eeb8 --- /dev/null +++ b/tests/globals-in-loop.template @@ -0,0 +1,6 @@ +Issue #7 +{{STR}} +{{#DATA}} + Item: {{.}} + String: {{STR}} +{{/DATA}}