模块:View:修订间差异

无编辑摘要
标签已被回退
无编辑摘要
标签手工回退
第24行: 第24行:
     end
     end


     text = text .. frame:getParent():expandTemplate{title = args[1], args = tmplOptions}
     text = text .. frame:getParent():expandTemplate{title = args[tmplName], args = tmplOptions}


     return text
     return text

2024年6月24日 (一) 17:13的版本

可在模块:View/doc创建此模块的帮助文档

local p = {} --p stands for package

function p.renderComponents( frame, payload)
    local args = frame.args
    
	-- 1. 载入 json 文件
    if not payload then
      payload = mw.loadJsonData( args["payload"] )
    end
    
    
    local text = ""
    for _, componentItem in ipairs(payload) do
      local tmplName, data = componentItem[1], componentItem[2]
      local tmplOptions = {}

      for key, value in pairs(data) do
        if type(value) == "table" and #value > 0 then
          tmplOptions[key] = p.renderComponents( frame, value )
        else
          tmplOptions[key] = value
        end
      end
    end

    text = text .. frame:getParent():expandTemplate{title = args[tmplName], args = tmplOptions}

    return text
end


return p