{% set modifier_css_enabled = applications | get_app_conf(application_id, 'features.css', false) | bool %} {% if modifier_css_enabled %} {%- include 'roles/srv-web-7-7-inj-css/templates/location.conf.j2' -%} {% endif %} lua_need_request_body on; body_filter_by_lua_block { -- initialize buffer ngx.ctx.buf = ngx.ctx.buf or {} local chunk, eof = ngx.arg[1], ngx.arg[2] if chunk ~= "" then table.insert(ngx.ctx.buf, chunk) end if not eof then ngx.arg[1] = nil return end -- on eof: concatenate and reset buffer local whole = table.concat(ngx.ctx.buf) ngx.ctx.buf = nil -- build head-injection snippets local head_snippets = {} {% for head_feature in ['css', 'matomo', 'port-ui-desktop', 'javascript', 'logout'] %} {% if applications | get_app_conf(application_id, 'features.' ~ head_feature, false) | bool %} head_snippets[#head_snippets + 1] = [=[ {%- include "roles/srv-web-7-7-inj-" ~ head_feature ~ "/templates/head_sub.j2" -%} ]=] {% endif %} {% endfor %} -- inject into local head_payload = table.concat(head_snippets, "\n") .. "" whole = string.gsub(whole, "", head_payload) {% if applications | get_app_conf(application_id, 'features.matomo', false) | bool %} -- build Matomo noscript tracking for body local body_matomo = [=[ {%- include 'roles/srv-web-7-7-inj-matomo/templates/body_sub.j2' -%} ]=] -- inject before whole = string.gsub(whole, "", body_matomo) {% endif %} ngx.arg[1] = whole }