mirror of
https://github.com/tests-always-included/mo.git
synced 2025-11-19 23:34:32 +01:00
Merge pull request #32 from andreax79/master
Pass arguments to function as environment variable MO_ALLOW_FUNCTION_ARGUMENTS
This commit is contained in:
29
demo/function-args
Executable file
29
demo/function-args
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This sources a simple script with the env. variables needed for the template.
|
||||
|
||||
cd "$(dirname "$0")" # Go to the script's directory
|
||||
source ../mo
|
||||
|
||||
export NAME="Alex"
|
||||
export ARRAY=( AAA BBB CCC )
|
||||
|
||||
# Include an external template
|
||||
INCLUDE() {
|
||||
cat "$MO_FUNCTION_ARGS"
|
||||
}
|
||||
|
||||
# Print section title
|
||||
TITLE() {
|
||||
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
||||
echo "$MO_FUNCTION_ARGS"
|
||||
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
||||
}
|
||||
|
||||
cat <<EOF | mo -u
|
||||
{{TITLE Part 1}}
|
||||
{{INCLUDE function-args-part1}}
|
||||
|
||||
{{TITLE Part 2}}
|
||||
{{INCLUDE function-args-part2}}
|
||||
EOF
|
||||
1
demo/function-args-part1
Normal file
1
demo/function-args-part1
Normal file
@@ -0,0 +1 @@
|
||||
Hello, my name is {{NAME}}.
|
||||
3
demo/function-args-part2
Normal file
3
demo/function-args-part2
Normal file
@@ -0,0 +1,3 @@
|
||||
{{#ARRAY}}
|
||||
* {{.}}
|
||||
{{/ARRAY}}
|
||||
Reference in New Issue
Block a user