If/Else Parameter Syntax

Hi all. I have seen and used this syntax for if/else logic based on the truthy/falsey-ness of parameter values: <<#parameters.public_read>>–acl public-read<</parameters.public_read>>

I can’t find this documented anywhere. I found out about it by inspecting an orb’s code. Is there anything else like this we can do that we should know about? Also, with this “IF” block, is there a syntax for the “ELSE” part? Thanks!

1 Like

Hi @amonica ,

Thank you for sharing your question on our forum!

We use mustache for the templating, and the conditional logic comes from that.
There is a way to check IF and IF NOT. I believe these could be combined to create an IF ELSE.

Here is the basic syntax:

IF

The following will be replaced with –acl public-read if parameters.public_read is true or not an empty string:

<<#parameters.public_read>>–acl public-read<</parameters.public_read>>

IF NOT

The following will be replaced with –acl public-read if parameters.public_read is false or an empty string:

<<^parameters.public_read>>–acl public-read<</parameters.public_read>>

In the case of IF-ELSE, this should work:

<<#parameters.public_read>>–acl public-read<</parameters.public_read>><<^parameters.public_read>>someothertext<</parameters.public_read>>

Let me know if this clears things up.

There is one page where this is in our documentation, but the syntax is not explicitly mentioned:

Best Regards

2 Likes