diff --git a/roles/srv-web-7-7-inj-compose/templates/location.lua.j2 b/roles/srv-web-7-7-inj-compose/templates/location.lua.j2 index b58b658e..9598d9a7 100644 --- a/roles/srv-web-7-7-inj-compose/templates/location.lua.j2 +++ b/roles/srv-web-7-7-inj-compose/templates/location.lua.j2 @@ -55,14 +55,20 @@ body_filter_by_lua_block { local head_payload = table.concat(head_snippets, "\n") .. "" whole = string.gsub(whole, "", head_payload) - {% if inj_enabled.matomo | bool %} - -- build Matomo noscript snippet for the body - local body_matomo = [=[ - {%- include 'roles/srv-web-7-7-inj-matomo/templates/body_sub.j2' -%} + -- build a list of body-injection snippets + local body_snippets = {} + + {% for body_feature in ['matomo', 'logout' ] %} + {% if applications | get_app_conf(application_id, 'features.' ~ body_feature, false) | bool %} + body_snippets[#body_snippets + 1] = [=[ + {%- include "roles/srv-web-7-7-inj-" ~ body_feature ~ "/templates/body_sub.j2" -%} ]=] - -- inject it right before - whole = string.gsub(whole, "", body_matomo) {% endif %} + {% endfor %} + + -- inject all collected snippets right before + local body_payload = table.concat(body_snippets, "\n") .. "" + whole = string.gsub(whole, "", body_payload) -- finally send the modified HTML out ngx.arg[1] = whole