From b22baa977688ab682d12477acbdce05a82f30801 Mon Sep 17 00:00:00 2001 From: Joseph Dalrymple Date: Tue, 4 Apr 2023 19:01:40 -0500 Subject: [PATCH] Added Functions/Helpers to README --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 0fac682..37fd6b7 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,37 @@ Output: ``` +### Helpers / Function Arguments with + +Function Arguments are not a part of the official Mustache implementation, and are more often associated with Handlebar's Helper functionality. + +`mo` allows for passing strings to functions. + +```handlebars +{{myfunc foo bar}} +``` + +For security reasons, this arguments are not immediately available to function calls without a flag. + +#### with `--allow-function-arguments` + +```bash +myfunc() { + # Outputs "foo, bar" + echo "$1, $2"; +} +``` + +#### Using `$MO_FUNCTION_ARGS` + +```bash +myfunc() { + # Outputs "foo, bar" + echo "${MO_FUNCTION_ARGS[0]}, ${MO_FUNCTION_ARGS[1]}"; +} +``` + + Concessions -----------