模块:Test:修订间差异
外观
小 Tabs module test 标签:已被回退 |
小无编辑摘要 标签:已被回退 |
||
| 第24行: | 第24行: | ||
local tabC = contentDiv:tag('div'):addClass('tab-c') | local tabC = contentDiv:tag('div'):addClass('tab-c') | ||
if firstContent then tabC:addClass('active') end | if firstContent then tabC:addClass('active') end | ||
tabC:tag('div'):addClass('inner-content'):wikitext(frame:preprocess(content)) | |||
tabC:tag('div'):addClass('inner-content') | |||
:wikitext('\n' .. frame:preprocess(content) .. '\n') | |||
firstContent = false | firstContent = false | ||
end | end | ||
2026年1月27日 (二) 03:54的版本
这个模块是干什么用的?
该模块用于测试,测试完请清空模块内的内容
基本用法
local p = {}
function p.函数名()
return '返回内容'
end
function p.函数名2()
return '返回内容2'
end
return
以上为最基本的用法,其他请自行学习Lua语言
其他
同样也有一个用于测试模板的模板,点这里进入
local p = {}
function p.render(frame)
local args = frame:getParent().args
local container = mw.html.create('div'):addClass('tabs-container')
local ul = container:tag('ul'):addClass('tabs-pages')
local firstTab = true
for i = 1, 20 do
local tabName = args['tab' .. i]
if tabName and tabName ~= "" then
local li = ul:tag('li'):addClass('tab')
if firstTab then li:addClass('active') end
li:tag('strong'):wikitext(tabName)
firstTab = false
end
end
local contentDiv = container:tag('div'):addClass('tabs-contents')
local firstContent = true
for i = 1, 20 do
local content = args['content' .. i]
if content and content ~= "" then
local tabC = contentDiv:tag('div'):addClass('tab-c')
if firstContent then tabC:addClass('active') end
tabC:tag('div'):addClass('inner-content')
:wikitext('\n' .. frame:preprocess(content) .. '\n')
firstContent = false
end
end
return tostring(container)
end
return p