加帕里图书馆 - 兽娘动物园中文维基
动物朋友 けものフレンズ KemonoFriends百科
模块:TitleCustomizer
此模块的文档可以在模块:TitleCustomizer/doc创建
local p = {}
-- 1. 这是编辑者在内页中调用的函数
function p.getTitleData(frame)
-- 获取调用时传入的参数 (即自定义标题文本)
local args = frame:getParent().args
-- 尝试获取第一个无名参数 ({{{1}}}) 或名为 'text' 的参数
local customText = args[1] or args.text or ''
-- 2. 使用 mw.html.create 安全地创建隐藏的 HTML 元素
-- 我们使用 class ".js-custom-title-data" 来代替之前失败的 id
local html = mw.html.create('span')
:addClass('js-custom-title-data')
:css('display', 'none') -- 隐藏这个元素
:wikitext(customText) -- 将自定义文本放入元素中
-- 3. 返回生成的 HTML 字符串
return tostring(html)
end
return p