匿名
未登录
登录
乐园数据管理室
搜索
查看“︁模块:Html”︁的源代码
来自乐园数据管理室
命名空间
模块
讨论
更多
更多
页面操作
阅读
查看源代码
历史
刷新
←
模块:Html
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您没有权限编辑
模块
命名空间内的页面。
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
local p = {} function p.wikitable(schema, data, options) local transpose, expandRow, expandRowKey, width, class if options then transpose = options.transpose or nil expandRow = options.expandRow or nil expandRowKey = options.expandRowKey or nil width = options.width or nil class = options.class or nil end local out = "" if schema[1]["scope"] then -- 数据为dict形式 if transpose then -- 转置 for _, field in ipairs(schema) do local rowHtml = "" rowHtml = rowHtml .. "<th>" .. field.label .. "</th>" for rowNumber, row in ipairs(data) do if row[field.scope] == nil then error("wikitable数据第" .. rowNumber .. "列 " .. field.scope .. " 的值为nil") end rowHtml = rowHtml .. "<td>" .. row[field.scope] .. "</td>" end rowHtml = "<tr>" .. rowHtml .. "</tr>" out = out .. rowHtml end elseif transpose == nil and expandRow == nil then for _, field in ipairs(schema) do out = out .. "<th>" .. field["label"] .. "</th>" end out = "<tr>" .. out .. "</tr>" for rowNumber, row in ipairs(data) do local rowHtml = "" for _, field in ipairs(schema) do if row[field.scope] == nil then error("wikitable数据第" .. rowNumber .. "行 " .. field.scope .. " 的值为nil") end rowHtml = rowHtml .. "<td>" .. row[field.scope] .. "</td>" end rowHtml = "<tr>" .. rowHtml .. "</tr>" out = out .. rowHtml end elseif expandRow then for _, field in ipairs(schema) do out = out .. "<th>" .. field["label"] .. "</th>" end out = "<tr>" .. out .. "</tr>" for rowNumber, row in ipairs(data) do local rowHtml = "" for _, field in ipairs(schema) do if row[field.scope] == nil then error("wikitable数据第" .. rowNumber .. "行 " .. field.scope .. " 的值为nil") end rowHtml = rowHtml .. "<td>" .. row[field.scope] .. "</td>" end rowHtml = '<tr class="mw-customtoggle-' .. row[expandRowKey] .. '">' .. rowHtml .. "</tr>" out = out .. rowHtml rowHtml = "" local expandContent = "" for _, field in ipairs(expandRow) do if row[field.scope] and #tostring(row[field.scope]) > 0 then expandContent = expandContent .. mw.ustring.format( [[<div class="expand-item"><div class="label">%s</div><div style="display: inline-block;">%s</div></div>]], field.label, row[field.scope] ) end end rowHtml = rowHtml .. '<td colspan="' .. #schema .. '" ><div class="flex-wrap" >' .. expandContent .. "</div></td>" rowHtml = '<tr class="mw-collapsible mw-collapsed" id="mw-customcollapsible-' .. row[expandRowKey] .. ">" .. rowHtml .. "</tr>" out = out .. rowHtml end end else -- 数据为array形式 if transpose then -- 转置 for i, label in ipairs(schema) do local rowHtml = "" rowHtml = rowHtml .. "<th>" .. label .. "</th>" for _, row in ipairs(data) do rowHtml = rowHtml .. "<td>" .. row[i] .. "</td>" end rowHtml = "<tr>" .. rowHtml .. "</tr>" out = out .. rowHtml end else for _, label in ipairs(schema) do out = out .. "<th>" .. label .. "</th>" end out = "<tr>" .. out .. "</tr>" for _, row in ipairs(data) do local rowHtml = "" for i, _ in ipairs(schema) do rowHtml = rowHtml .. "<td>" .. row[i] .. "</td>" end rowHtml = "<tr>" .. rowHtml .. "</tr>" out = out .. rowHtml end end end out = mw.ustring.format( '<table class="%s" %s >%s</table>\n', class or "wikitable", width and 'style="width:' .. width .. ';"' or "", out ) return out end function p.h2(text) return "<h2>" .. text .. "</h2>" end function p.h3(text) return "<h3>" .. text .. "</h3>" end function p.h4(text) return "<h4>" .. text .. "</h4>" end function p.p(text) return "<p>" .. text .. "</p>" end function p.ul(array) if #array > 0 then local text = "" for _, v in ipairs(array) do if #v > 0 then text = text .. "<li>" .. v .. "</li>" end end return "<ul>" .. text .. "</ul>" end return "" end function p.ol(array) if #array > 0 then local text = "" for _, v in ipairs(array) do if #v > 0 then text = text .. "<li>" .. v .. "</li>" end end return "<ol>" .. text .. "</ol>" end return "" end return p
该页面使用的模板:
模块:Html/doc
(
查看源代码
)
返回
模块:Html
。
导航
导航
首页
最近更改
随机页面
翻译查询
异度神剑
异度神剑3
异度神剑X
wiki工具
wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志