From ce600dd8e70fee2d1fb54289e8114bd950ca69cc Mon Sep 17 00:00:00 2001 From: Adam Pippin Date: Mon, 15 Feb 2021 12:03:31 -0800 Subject: [PATCH] Add !expr to readme and concat/concat* functions --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fa8a0e2..a5bc86f 100644 --- a/README.md +++ b/README.md @@ -237,9 +237,45 @@ Resources: The true/false values can include maps/arrays/any other valid YAML. +#### !expr + +Evaluate an expression and insert the result. + +Expects a scalar representing an expression using the same notatation as !if (and +outlined below). + +If the expression evaluates down to a single value, it will be inserted as a +scalar. If it evaluates down to multiple values, it will be inserted as an array. + +Example: + +``` +cfnpp: + variables: + A: 1 + B: 2 + C: !expr 1 2 gt + +Math: + IsALessThanB: !expr A B lt + AllMyFavouriteVariables: !expr A B + ValueOfC: !var C +``` + +Result: + +``` +Math: + IsALessThanB: True + AllMyFavouriteVariables: + - 1 + - 2 + ValueOfC: False +``` + #### Expressions -Expressions are composed of space separated values and operators. Value components +Expressions are composed of space separated values and operators. Valid components are: * Numeric Literals: Any integer or float value. @@ -256,6 +292,9 @@ are: - lte: less than or equal - and: boolean and - or: boolean or +* Function: Currently supported functions are: + - concat: Concatenate as strings two values off of the stack + - concat\*: Concatenate all values currently on the stack down to a single value. ## Usage