HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux mail.btech-izolacje.pl 5.15.0-140-generic #150-Ubuntu SMP Sat Apr 12 06:00:09 UTC 2025 x86_64
User: pewna6876 (1017)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: //opt/imunify360-webshield/lualib/resty/template/html.lua
local template = require "resty.template"
local setmetatable = setmetatable
local escape = template.escape
local concat = table.concat
local pairs = pairs
local type = type

local function tag(name, content, attr)
    local r, a = {}, {}
    content = content or attr
    r[#r + 1] = "<"
    r[#r + 1] = name
    if attr then
        for k, v in pairs(attr) do
            if type(k) == "number" then
                a[#a + 1] = escape(v)
            else
                a[#a + 1] = k .. '="' .. escape(v) .. '"'
            end
        end
        if #a > 0 then
            r[#r + 1] = " "
            r[#r + 1] = concat(a, " ")
        end
    end
    if type(content) == "string" then
        r[#r + 1] = ">"
        r[#r + 1] = escape(content)
        r[#r + 1] = "</"
        r[#r + 1] = name
        r[#r + 1] = ">"
    else
        r[#r + 1] = " />"
    end
    return concat(r)
end

local html = { __index = function(_, name)
    return function(attr)
        if type(attr) == "table" then
            return function(content)
                return tag(name, content, attr)
            end
        else
            return tag(name, attr)
        end
    end
end }

template.html = setmetatable(html, html)

return template.html