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

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


         local parsed = getTemplateMeta(frame, tplPath)
         local parsed = getTemplateMeta(frame, tplPath)
        local extra = ""
        if ok and dp and dp.flattenField then
            local dataPage = tplPath .. ".json"
            extra = dp.flattenField({ args = { id, dataPage } })
        end
        local basePriority = 1
        if parsed and parsed.priority ~= nil then
            if type(parsed.priority) == "number" then
                basePriority = parsed.priority
            else
                local pnum = tonumber(parsed.priority)
                if pnum then basePriority = pnum end
            end
        end
         for _, sw in ipairs(switches) do
         for _, sw in ipairs(switches) do
             local keys = parsed[sw] or {}
             local keys = parsed[sw] or {}
Строка 398: Строка 415:
                         switchKeyToTemplates[sw][key] = {}
                         switchKeyToTemplates[sw][key] = {}
                         table.insert(switchKeyOrder[sw], key)
                         table.insert(switchKeyOrder[sw], key)
                    end
                    local extra = ""
                    if ok and dp and dp.flattenField then
                        local dataPage = tplPath .. ".json"
                        extra = dp.flattenField({ args = { id, dataPage } })
                     end
                     end
                     local tplStr
                     local tplStr
Строка 413: Строка 425:
                         tplStr = makeTplCall(tplPath, sw, key, id, extra)
                         tplStr = makeTplCall(tplPath, sw, key, id, extra)
                     end
                     end
                     local priority = 1
                     local priority = basePriority
                    if parsed and parsed.priority ~= nil then
                        if type(parsed.priority) == "number" then
                            priority = parsed.priority
                        else
                            local pnum = tonumber(parsed.priority)
                            if pnum then priority = pnum end
                        end
                    end


                     local entry
                     local entry
Строка 444: Строка 448:
                 end
                 end
             end
             end
        end
        if parsed and parsed.cardTag and parsed.cardTag ~= "" then
            local key = "cardTag"
            if not switchKeyToTemplates.card[key] then
                switchKeyToTemplates.card[key] = {}
                table.insert(switchKeyOrder.card, key)
            end
            local tplTagStr = makeTplCall(tplPath, "cardTag", key, id, extra)
            table.insert(switchKeyToTemplates.card[key], {
                tplLabel = "",
                tplContent = "",
                tplTag = tplTagStr,
                source = { kind = kind, name = name, pathName = pathName, tplPath = tplPath },
                priority = basePriority,
                idx = #switchKeyToTemplates.card[key] + 1
            })
         end
         end
     end
     end