Pongo2 as templating engine
The template engine used by Hoverfly looks stale (Raymond) I would propose to consider porting Pongo2 as the template engine of choice. Pongo2 is active, has similar approach to Raymond but includes more features
Thanks @petkostas. Will take a look this week.
looks promising. As long as it supports handlebars for backward compatibility, and is fast (because hoverfly is used for load testing in many places), it's worth a try.
This should cover the requirements for Hoverfly https://pkg.go.dev/github.com/flosch/pongo2#RegisterFilter Might require a few changes here and there, but we could also introduce helper methods, allowing the registration of extensions (tags/filters, etc) dynamically, without having to wait for a new release of the project. Regarding performance, we need to check, yet I believe, as it's more maintained and adopted that should match Raymond. In the case there are incpompatibilies, a flag could be introduced to switch template engine over the other, similar to how Django supports them
Also as I mentioned, I am fairly new to GO so I am not really aware of all the alternatives, if there is something else more promising feel free to drop it here, I can possibly provide some context after 10+ years of working with Jinja and Django templates.
Hi @tommysitu I have a very weird case when JSON is a value of an attribute of some XML which in its turn a property value of a JSON e.g.
{
"prop": "<table baz=\"{"version":1}\">Foo</table>"
}
And I wonder if it's possible to access version property of the innermost JSON using current templates (Raymond) or any other future templating mechanism.
@tommysitu someone has done benchmarking on go templates engine and it seems pongo2 is much faster than raymonds(named as handlebars in the link). You can check below github link for benchmarking results. If it seems promising, then probably, we can keep both for a while by taking the option from the user to use and then deprecate it other one after sometime.
https://github.com/SlinSo/goTemplateBenchmark#full-featured-template-engines-1 https://github.com/SlinSo/goTemplateBenchmark
@petkostas Is there a way in pongo2 to access context in the filter functions?
Secondly, can we do a method call as {{<method name> <args1> <args2>}}. I see that method can be called via {{method(arg1,arg2)}}. I could not find these two in their documentation. These are required for backward compatibility.
@kapishmalik not sure for this, as I have not personally used pongo2 (but rather Django) for the first question, it should be available (context). I will try to find some time and do some tests with it and get back