Import Liquid Map into set-body #76
-
I managed to get a working solution to create a simple map using the toolkit. However, I would like to set-body from a liquid template file, has anyone achieved this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hello @WarrenKinley! Thank you using toolkit! I will try to help you here. If I understand correctly, you have a file which contains a body. This file contains a liquid template. What you want to achieve is to paste the file as a content for the policy in similar manner as below context.SetBody(File.ReadAllText("body.liquid"), new SetBodyConfig() { Template = "liquid" }); Currently, compiler does not support loading external files. You need to copy and paste the value in the policy itself. e.g. context.SetBody(
"""
Your liquid template
""", new SetBodyConfig {
Template = "liquid",
}); I think, this is a great idea to create an improvement to the compiler. |
Beta Was this translation helpful? Give feedback.
-
Hi @Mielek, after looking into this I re-thought the implementation of this and wanted to keep it simple and secure. Instead of passing the method call and having to invoke and validate this I instead keep the SetBodyCompiler class the same apart from if liquid template is passed in the config then the first parameter is checked to see if a valid file path. If a valid file path passed and the file exists then the set-body value is populated from the file contents, otherwise it populates it from the value sent, as before. Therefore, any invalid file paths are bubbled up in the compiled policy. This is valid: An invalid call: All existing tests pass and I've added some new ones. |
Beta Was this translation helpful? Give feedback.
Hello @WarrenKinley! Thank you using toolkit! I will try to help you here.
If I understand correctly, you have a file which contains a body. This file contains a liquid template. What you want to achieve is to paste the file as a content for the policy in similar manner as below
Currently, compiler does not support loading external files. You need to copy and paste the value in the policy itself. e.g.
I think, this is a great idea to create an improvement to the compiler.