|
|
第1行: |
第1行: |
| local p = {}
| |
|
| |
|
| function p.paginate(frame)
| |
| -- 获取参数
| |
| local pages = frame.args.pages or ""
| |
| local pageList = mw.text.split(pages, ",")
| |
| local output = ""
| |
|
| |
| -- 生成内容
| |
| for _, page in ipairs(pageList) do
| |
| page = mw.text.trim(page) -- 去掉前后空格
| |
| local pageTitle = mw.title.new(page)
| |
|
| |
| -- 检查页面标题是否有效
| |
| if pageTitle and pageTitle.exists then
| |
| -- 添加标题
| |
| output = output .. string.format("=== %s ===\n", pageTitle.text)
| |
|
| |
| -- 获取页面内容
| |
| local content = pageTitle:getContent() or "内容无法加载"
| |
|
| |
| -- 直接添加内容
| |
| output = output .. content .. "\n\n"
| |
| else
| |
| output = output .. string.format("=== %s ===\n内容无法加载(页面不存在)\n\n", page)
| |
| end
| |
| end
| |
|
| |
| return output
| |
| end
| |
|
| |
| return p
| |
这个模块是干什么用的?
该模块用于测试,测试完请清空模块内的内容
基本用法
local p = {}
function p.函数名()
return '返回内容'
end
function p.函数名2()
return '返回内容2'
end
return
以上为最基本的用法,其他请自行学习Lua语言
其他
同样也有一个用于测试模板的模板,点这里进入