Модуль:Сущность: различия между версиями

мНет описания правки
мНет описания правки
Строка 131: Строка 131:
         tagSet = {}
         tagSet = {}
     }
     }
    if frame then
        local mainArgs = getArgs(frame, { removeBlanks = false })
        local rawTopCardTag = trim(mainArgs.cardTag or "")
        if rawTopCardTag and rawTopCardTag ~= "" then
            local ok, processed = pcall(function() return frame:preprocess(rawTopCardTag) end)
            local topCardTag = ""
            if ok and processed then topCardTag = trim(processed) else topCardTag = trim(rawTopCardTag) end
            if topCardTag ~= "" then
                for tag in string.gmatch(topCardTag, "[^,]+") do
                    local t = trim(tag)
                    if t ~= "" and not merged.tagSet[t] then
                        merged.tagSet[t] = true
                        table.insert(merged.tags, t)
                    end
                end
            end
        end
    end
     for _, callKey in ipairs(keyOrder or {}) do
     for _, callKey in ipairs(keyOrder or {}) do
         local entries = keyToTemplates[callKey] or {}
         local entries = keyToTemplates[callKey] or {}
Строка 402: Строка 423:
                     local entry
                     local entry
                     if sw == "card" then
                     if sw == "card" then
                        local cardTagStr = ""
                        local okTag, expandedTag = pcall(function()
                            return trim(frame:preprocess(makeTplCall(tplPath, "cardTag", key, id, extra) or ""))
                        end)
                        if okTag and expandedTag and expandedTag ~= "" then
                            cardTagStr = expandedTag
                        end
                         entry = {
                         entry = {
                             tplLabel = tplLabelStr,
                             tplLabel = tplLabelStr,
                             tplContent = tplContentStr,
                             tplContent = tplContentStr,
                             cardTag = finalCardTag,
                             cardTag = parsed.cardTag,
                             source = { kind = kind, name = name, pathName = pathName, tplPath = tplPath },
                             source = { kind = kind, name = name, pathName = pathName, tplPath = tplPath },
                             priority = priority,
                             priority = priority,
Строка 491: Строка 504:
             local entry
             local entry
             if sw == "card" then
             if sw == "card" then
                local cardTagStr = ""
                local okTag, expandedTag = pcall(function()
                    return trim(frame:preprocess(makeTplCall(tplPath, "cardTag", key, "", "") or ""))
                end)
                if okTag and expandedTag and expandedTag ~= "" then
                    cardTagStr = expandedTag
                end
                local finalCardTag = cardTagStr
                if finalCardTag == "" and parsed and parsed.cardTag ~= nil then
                    if type(parsed.cardTag) == "table" then
                        local maybe = parsed.cardTag[key]
                        if maybe and type(maybe) ~= "table" then
                            finalCardTag = tostring(maybe)
                        else
                            finalCardTag = ""
                        end
                    else
                        finalCardTag = tostring(parsed.cardTag)
                    end
                end
                 entry = {
                 entry = {
                     tplLabel = makeTplCall(tplPath, "cardLabel", key, ""),
                     tplLabel = makeTplCall(tplPath, "cardLabel", key, ""),
                     tplContent = makeTplCall(tplPath, "cardContent", key, ""),
                     tplContent = makeTplCall(tplPath, "cardContent", key, ""),
                    cardTag = finalCardTag,
                     source = { kind = "", name = tplPath, pathName = tplPath, tplPath = tplPath },
                     source = { kind = "", name = tplPath, pathName = tplPath, tplPath = tplPath },
                     priority = 1,
                     priority = 1,