mirror of
https://github.com/tests-always-included/mo.git
synced 2025-11-19 23:34:32 +01:00
Better associative array handling
Bug: Did not properly detect the length of an array in mustache-test because I neglected to use `[@]` after the array name. This closes issue #6. Feature: Made {{ARRAY_NAME}} implode array values with commas. Feature: Added an associative array demo script.
This commit is contained in:
16
demo/associative-arrays
Executable file
16
demo/associative-arrays
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare -A DATA
|
||||
DATA=([one]=111 [two]=222)
|
||||
|
||||
cat <<EOF | . ~/bin/mo
|
||||
Accessing data directly:
|
||||
DATA: {{DATA}}
|
||||
One: {{DATA.one}}
|
||||
Two: {{DATA.two}}
|
||||
|
||||
Things in DATA:
|
||||
{{#DATA}}
|
||||
Item: {{.}}
|
||||
{{/DATA}}
|
||||
EOF
|
||||
Reference in New Issue
Block a user