From f3d4db5f72e2f0344dbe9e286a6f95d1914f4a37 Mon Sep 17 00:00:00 2001 From: Daniel Akulenok Date: Tue, 14 May 2024 14:36:54 +0200 Subject: [PATCH] refactor: Replace Jinja2 macros with direct logic in zone and view templates --- templates/named.conf.generator.j2 | 6 ++---- templates/named.conf.view.j2 | 5 ++--- templates/named.conf.zone.j2 | 4 +--- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/templates/named.conf.generator.j2 b/templates/named.conf.generator.j2 index 56bd502..e7d4598 100644 --- a/templates/named.conf.generator.j2 +++ b/templates/named.conf.generator.j2 @@ -54,10 +54,8 @@ options { {% include 'named.conf.trust-anchors.j2' %} {% endif %} {% if item.zones is defined and item.zones %} -{% from 'named.conf.zone.j2' import zones with context %} -{{ zones(item.zones) }} +{% include 'named.conf.zone.j2' %} {% endif %} {% if item.view is defined and item.view %} -{% from 'named.conf.view.j2' import view with context %} -{{ view(item.view) }} +{% include 'named.conf.view.j2' %} {% endif %} diff --git a/templates/named.conf.view.j2 b/templates/named.conf.view.j2 index 8191024..c1832a6 100644 --- a/templates/named.conf.view.j2 +++ b/templates/named.conf.view.j2 @@ -1,5 +1,4 @@ -{% macro view(views) %} -{% for view in views if views is iterable %} +{% for view in item.view if item.view is iterable %} view {{ view.name }} { {% filter indent(bind9_config_indent, true) %} {{ ('match-recursive-only ' + functions.named_boolean(view.match_recursive_only) + ';\n') if view.match_recursive_only is defined -}} @@ -75,4 +74,4 @@ view {{ view.name }} { {{ trust_anchors(view.trust_anchors) -}} {% endif %} {% endfilter %} -};{% endfor %}{% endmacro %} \ No newline at end of file +};{% endfor %} diff --git a/templates/named.conf.zone.j2 b/templates/named.conf.zone.j2 index 425b3a1..1e924b2 100644 --- a/templates/named.conf.zone.j2 +++ b/templates/named.conf.zone.j2 @@ -1,6 +1,5 @@ # Zones Macro -{% macro zones(zones) -%} -{% for zone in zones %} +{% for zone in item.zones %} zone "{{ zone.name }}" { {% filter indent(bind9_config_indent, true) %} # Zone {{ zone.name }} type {{ zone.type }} @@ -159,4 +158,3 @@ parental-source-v6 {{ zone.parental_source_v6.address -}} }; {% endfor %} -{% endmacro %} \ No newline at end of file