Skip to content

Pongo2 as templating engine #1023

Open
Open

Description

@petkostas

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

Activity

  1. tommysitu commented on Sep 12, 2022

    @tommysitu
    Member

    Thanks @petkostas. Will take a look this week.

  2. tommysitu commented on Sep 14, 2022

    @tommysitu
    Member

    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.

  3. petkostas commented on Sep 15, 2022

    @petkostas
    ContributorAuthor

    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

  4. petkostas commented on Sep 15, 2022

    @petkostas
    ContributorAuthor

    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.

  5. moikot commented on Oct 27, 2022

    @moikot

    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=\"{&quot;version&quot;: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.

  6. kapishmalik commented on Jan 4, 2023

    @kapishmalik
    Collaborator

    @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

  7. kapishmalik commented on Jan 5, 2023

    @kapishmalik
    Collaborator

    @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.

  8. petkostas commented on Jan 11, 2023

    @petkostas
    ContributorAuthor

    @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

  9. c-harding commented on Oct 22, 2025

    @c-harding

    As Raymond was archived this year, it would be good to have a replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions