mirror of
https://github.com/tests-always-included/mo.git
synced 2024-12-18 16:27:52 +00:00
Allowing access to globals while in a loop
This used to make a name like DATA.0.STR. Since bash doesn't like using multi-dimensional arrays, we can shortcut things and just assume that STR referes to the global variable here. This closes issue #7
This commit is contained in:
parent
70cc736b4a
commit
e623b16bb8
2
mo
2
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}"
|
||||
|
2
tests/globals-in-loop.env
Normal file
2
tests/globals-in-loop.env
Normal file
@ -0,0 +1,2 @@
|
||||
STR=abc
|
||||
DATA=(111 222)
|
6
tests/globals-in-loop.expected
Normal file
6
tests/globals-in-loop.expected
Normal file
@ -0,0 +1,6 @@
|
||||
Issue #7
|
||||
abc
|
||||
Item: 111
|
||||
String: abc
|
||||
Item: 222
|
||||
String: abc
|
6
tests/globals-in-loop.template
Normal file
6
tests/globals-in-loop.template
Normal file
@ -0,0 +1,6 @@
|
||||
Issue #7
|
||||
{{STR}}
|
||||
{{#DATA}}
|
||||
Item: {{.}}
|
||||
String: {{STR}}
|
||||
{{/DATA}}
|
Loading…
Reference in New Issue
Block a user