Lesson 8 - YAML Escaping
Since Archy YAML files are written in YAML, it is important to remember that you need to escape values accordingly. In many cases this isn't an issue, but we wanted to bring it up to make sure you're aware of this.
Here's an example. Let's say we are entering Architect expression text for the condition property on a decision action, and the condition we want to test is this Architect expression:
Append("hello ", "world") == "hello world"
Initially you might think this is what you should enter in the YAML for the decision action:
- decision:
condition:
exp: "Append("hello ", "world") == "hello world""
but that is not how you should handle those embedded quotes like what you see around the words hello and world. In this case we are entering a string value for the expression text and since it does contain those embedded quotes, they need to be escaped. It's not hard but what you want to do is add backslashes in front of those embedded quotes:
- decision:
condition:
exp: "Append(\"hello \", \"world\") == \"hello world\""
That's how you express the string:
Append("hello ", "world") == "hello world"`
in YAML. This pretty much boils down to a "make sure you understand YAML" before attempting to write YAML. Yeah, a lot of it might be trial and error but knowing details like this will help.
If it helps, Archy does have a preprocess
command where you can have it pre-process a YAML file which will run through the YAML, embed all externally referenced objects, apply substitutions, and write out resulting JSON so that you can see what the values are that will be processed by the Archy processor.
To see help on this command, you can run:
archy preprocess --help
Tutorial Main | Previous Lesson
Archy - Ver. 2.33.1, generated on January 3, 2025