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

Нет описания правки
мНет описания правки
Строка 98: Строка 98:


     -- содержимое полей
     -- содержимое полей
     for compositeKey, originalLabel in pairs(merged.labelOverrides or {}) do
     for compositeKey, displayLabel in pairs(merged.labelOverrides or {}) do
         if originalLabel and originalLabel ~= "" then
         if displayLabel and displayLabel ~= "" then
             parts[#parts + 1] = mw.text.encode(compositeKey .. "_label") .. "=" .. mw.text.encode(originalLabel)
             parts[#parts + 1] = mw.text.encode(compositeKey .. "_label") .. "=" .. displayLabel
         end
         end
     end
     end
Строка 127: Строка 127:
         tagSet = {}
         tagSet = {}
     }
     }
     for _, section in ipairs(keyOrder or {}) do
     for _, callKey in ipairs(keyOrder or {}) do
         local entries = keyToTemplates[section] or {}
         local entries = keyToTemplates[callKey] or {}
         if #entries > 0 then
         if #entries > 0 then
             table.sort(entries, function(a, b)
             table.sort(entries, function(a, b)
Строка 135: Строка 135:
             end)
             end)
             for _, e in ipairs(entries) do
             for _, e in ipairs(entries) do
                 local label = trim(frame:preprocess(e.tplLabel or "") or "")
                 local displayLabel = trim(frame:preprocess(e.tplLabel or "") or "")
                 local content = trim(frame:preprocess(e.tplContent or "") or "")
                 local content = trim(frame:preprocess(e.tplContent or "") or "")
                 if label ~= "" then
                local compositeKey = (callKey:find("_", 1, true)) and callKey or ("Сущность_" .. callKey)
                local section = (callKey:find("_", 1, true)) and callKey:match("^([^_]+)") or "Сущность"
 
                 if displayLabel ~= "" or content ~= "" then
                     if not merged.sectionsMap[section] then
                     if not merged.sectionsMap[section] then
                         merged.sectionsMap[section] = true
                         merged.sectionsMap[section] = true
                         table.insert(merged.sections, section)
                         table.insert(merged.sections, section)
                     end
                     end
                    local compositeKey = tostring(section) .. "-" .. tostring(label)
                     merged.labelOverrides[compositeKey] = displayLabel
 
                     merged.labelOverrides[compositeKey] = label
                     merged.contentByKey[compositeKey] = content
                     merged.contentByKey[compositeKey] = content