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

Нет описания правки
Нет описания правки
Строка 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 = ok and processed or rawTopCardTag
            topCardTag = trim(topCardTag)
            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 {}
Строка 186: Строка 168:
                         merged.labelLists[section] = cur
                         merged.labelLists[section] = cur
                     end
                     end
                     local rawTag = e.cardTag or ""
                     if e.cardTag and e.cardTag ~= "" then
                    local expandedTag = ""
                         if not merged.tagSet[e.cardTag] then
                    if rawTag ~= "" and frame then
                             merged.tagSet[e.cardTag] = true
                        expandedTag = trim(frame:preprocess(rawTag) or "") or ""
                             table.insert(merged.tags, e.cardTag)
                    else
                        expandedTag = trim(rawTag)
                    end
                   
                    if expandedTag ~= "" then
                         if not merged.tagSet[expandedTag] then
                             merged.tagSet[expandedTag] = true
                             table.insert(merged.tags, expandedTag)
                         end
                         end
                     end
                     end
Строка 426: Строка 400:
                         end
                         end
                     end
                     end
                    local cardTagValue = parsed.cardTag
                    if sw == "card" and cardTagValue and cardTagValue ~= "" and extra and extra ~= "" then
                        local params = {}
                        for chunk in string.gmatch(extra, "[^|]+") do
                            local pk, pv = chunk:match("^(.-)=(.*)$")
                            if pk and pv then
                                params[trim(pk)] = pv
                            end
                        end
                        cardTagValue = cardTagValue:gsub("{{{([^}]+)}}}", function(name)
                            name = trim(name or "")
                            return params[name] or ""
                        end)
                    end
                     local entry
                     local entry
                     if sw == "card" then
                     if sw == "card" then
Строка 431: Строка 420:
                             tplLabel = tplLabelStr,
                             tplLabel = tplLabelStr,
                             tplContent = tplContentStr,
                             tplContent = tplContentStr,
                             cardTag = parsed.cardTag,
                             cardTag = cardTagValue,
                             source = { kind = kind, name = name, pathName = pathName, tplPath = tplPath },
                             source = { kind = kind, name = name, pathName = pathName, tplPath = tplPath },
                             priority = priority,
                             priority = priority,
Строка 471: Строка 460:


     local out = {}
     local out = {}
   
     if #errors > 0 then
     if #errors > 0 then
         table.insert(out, '{{сущность/infobox|' .. table.concat(errors, "\n") .. '}}')
         table.insert(out, '{{сущность/infobox|' .. table.concat(errors, "\n") .. '}}')