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

Нет описания правки
Нет описания правки
 
Строка 62: Строка 62:
     end
     end
     return nil
     return nil
end
local function each_raw_compound_arg(sources, fn)
    for _, source in ipairs(sources) do
        if source then
            for k in pairs(source) do
                if type(k) == 'string' and k:find('_', 1, true) then
                    local base, rem = split_first_underscore(k)
                    if base and rem then
                        fn(source, k, base, rem)
                    end
                end
            end
        end
    end
end
end


Строка 88: Строка 73:


     if field ~= '' and label ~= '' then
     if field ~= '' and label ~= '' then
         local result = nil
         local value = get_raw_arg(sources, field .. '_' .. label)
        each_raw_compound_arg(sources, function(source, key, base, rem)
        if value ~= nil then
            if base == field and trim(strip_trailing_digits(rem)) == label then
             return tostring(value)
                local value = tostring(source[key])
         end
                if result then
                    result = result .. '\n' .. value
                else
                    result = value
                end
             end
        end)
         if result then return result end
     end
     end