模組:MakeTable/examples
模块文档[创建]
您可能想要创建本Scribunto模块的文档。 编者可以在本模块的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 请在/doc子页面中添加分类。本模块的子页面。 |
local MakeTable = require("Module:MakeTable")
local R = function(rstr)
return function ()
return rstr
end
end
local examples = {
basic = R(MakeTable({
content = {
{"Content1.1","Content1.2"},
{"Content2.1","Content2.2"}
}
})),
wikitable = R(MakeTable({
class = {"wikitable"},
content = {
{"Content1.1","Content1.2"},
{"Content2.1","Content2.2"}
}
})),
wikitable_sortable_title = R(MakeTable({
class = {"wikitable","sortable"},
titles = {"title1","title2"},
content = {
{"Content1.1","Content1.2"},
{"Content2.1","Content2.2"}
}
})),
wikitable_caption = R(MakeTable({
class = {"wikitable"},
caption = "标题",
content = {
{"Content1.1","Content1.2"},
{"Content2.1","Content2.2"}
}
})),
}
local p = {}
p.all = function()
local force_order = {"basic","wikitable","wikitable_sortable_title","wikitable_caption"}
local FOFVtable = {}
for y,x in pairs(force_order) do
FOFVtable[x] = y
end
local cont = mw.html.create( 'div' )
for _,y in ipairs(force_order) do
cont:tag("h3"):wikitext(y)
cont:node(examples[y]())
end
for x,y in pairs(examples) do
if not FOFVtable[x] then
cont:tag("h3"):wikitext(x)
cont:node(y())
end
end
return tostring(cont)
end
for x,y in pairs(examples) do
p[x] = y
end
return p