From: Nicki Křížek Date: Wed, 1 Apr 2026 17:42:38 +0000 (+0200) Subject: Allow instantiating template dataclasses in jinja2 templates X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=dddb0673517ccbba50941d91dec3c55e1f7f52b4;p=thirdparty%2Fbind9.git Allow instantiating template dataclasses in jinja2 templates In some cases, the template data might need to be set directly in the jinja2 templates using `{% set %}`. Expose the template dataclasses to the templates so we can use these existing classes, rather than creating ad-hoc data containers. --- diff --git a/bin/tests/system/isctest/template.py b/bin/tests/system/isctest/template.py index f81b423f10d..8065f4acbbd 100644 --- a/bin/tests/system/isctest/template.py +++ b/bin/tests/system/isctest/template.py @@ -45,6 +45,11 @@ class TemplateEngine: variable_start_string="@", variable_end_string="@", ) + # allow instantiating the template dataclasses in jinja2 templates when + # using {% set %} + self.j2env.globals["Nameserver"] = Nameserver + self.j2env.globals["TrustAnchor"] = TrustAnchor + self.j2env.globals["Zone"] = Zone def render( self,