From 4c329515f78beda9dbdd9b3fd523cad4b22fafdf Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Wed, 18 Jan 2017 21:47:53 -0500 Subject: [PATCH] refactored. --- keepalived/templates/config.jinja | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/keepalived/templates/config.jinja b/keepalived/templates/config.jinja index e02881f..fe0b3e3 100644 --- a/keepalived/templates/config.jinja +++ b/keepalived/templates/config.jinja @@ -6,23 +6,19 @@ {{- '\n' -}} {%- elif data is string or data is number -%} {{- data }}{{ '\n' -}} - {%- elif data is mapping -%} - {%- if recurse > 0 -%} - {{- '{\n' -}} - {%- endif -%} - {%- for item in data|dictsort -%} - {{- item[key] }} {{ keepalived_config(item[value], recurse) -}} - {%- endfor -%} - {%- if recurse > 0 -%} - {{- '}\n' -}} - {%- endif -%} {%- else -%} - {%- if recurse > 0 -%} + {%- if recurse > 0 -%} {{- '{\n' -}} {%- endif -%} - {%- for item in data -%} - {{- keepalived_config(item) -}} - {%- endfor -%} + {%- if data is mapping -%} + {%- for item in data|dictsort -%} + {{- item[key] }} {{ keepalived_config(item[value], recurse) -}} + {%- endfor -%} + {%- else -%} + {%- for item in data -%} + {{- keepalived_config(item) -}} + {%- endfor -%} + {%- endif -%} {%- if recurse > 0 -%} {{- '}\n' -}} {%- endif -%}