From 4ea5f2c6be54a68a67f0d5615ef8c13af9332563 Mon Sep 17 00:00:00 2001 From: Jean-Marie Mineau Date: Sun, 17 Jul 2022 20:13:18 +0200 Subject: [PATCH] implement inline config --- README.md | 4 +++- templates/http_server.j2 | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1e415cb..c512464 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ http_sites: `location`: templates: - `template` + config: + - `config` ... ``` @@ -53,7 +55,7 @@ http_sites: `root_snippets` is a list of snippets/templates (To be determine) containing configurations for the http server. -`locations` is a dictionnary of location block. `location` (the key of an item) is the location (eg, "/"), `template` is the jinja template defining the contant of the location block. Other variables can be added to the location block depending on the template used. +`locations` is a dictionnary of location block. `location` (the key of an item) is the location (eg, "/"), `template` are the jinja templates defining the contant of the location block. Other variables can be added to the location block depending on the template used. `config` is a string added directly to the config of the location block. Inside the templates, `server_name` is accessed with `{{ item.key }}`, en variables of the server block with `{{ item.value.varname }}`. diff --git a/templates/http_server.j2 b/templates/http_server.j2 index 11b753f..1fa9a29 100644 --- a/templates/http_server.j2 +++ b/templates/http_server.j2 @@ -52,12 +52,19 @@ server { {% for location in (item.value.locations | default({}) | dict2items) -%} location {{ location.key }} { {% filter indent(width=8) -%} - {% for template in (location.value.templates | default([])) -%} - {% include template -%} - {%- endfor %} + {%- for config in (location.value.config | default([])) -%} + {{ config }} + + {%- endfor -%} + {%- for template in (location.value.templates | default([])) -%} + {% include template %} + + {%- endfor -%} {%- endfilter %} + } - {%- endfor %} + + {% endfor %} }