跳转到内容
打开/关闭搜索
搜索
打开/关闭菜单
5
条目
3
文件
13
用户
619
编辑
久远澪Wiki
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
打开/关闭外观设置菜单
无法加载偏好设置。请检查您的网络连接并重试。
重试
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
查看“︁Module:按钮”︁的源代码
来自久远澪Wiki
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
更多
工具
链入页面
相关更改
页面信息
←
Module:按钮
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
-- 按钮模板:生成带图标与文字标签的链接按钮(Template:按钮) -- 使用 Lua 生成 <a> 标签,避免 MediaWiki 自动把 href 中的裸 URL 外链化。 local p = {} local function isExternalUrl(url) if not url then return false end return url:match('^%s*https?://') ~= nil or url:match('^%s*//') ~= nil or url:match('^%s*ftp://') ~= nil end function p.render(frame) local args = frame:getParent().args local link = args['链接'] or '' local external = args['外部链接'] or '' local label = args['label'] or args['标签'] or '' local icon = args['图标'] or '' local image = args['图片'] or '' local shape = args['形状'] or '圆角矩形' local size = args['尺寸'] or '64' local isExternal = (external ~= '') or isExternalUrl(link) local html = mw.html.create('a') html:addClass('wiki-button-anchor') if isExternal then html:attr('href', link) :attr('target', '_blank') :attr('rel', 'noopener noreferrer') else html:attr('href', frame:preprocess('{{fullurl:' .. link .. '}}')) end local button = html:tag('span') button:addClass('wiki-button') button:addClass('wiki-button-' .. shape) local iconSpan = button:tag('span'):addClass('wiki-button-icon') if image ~= '' then iconSpan:wikitext(string.format('[[File:%s|%spx|link=]]', image, size)) elseif icon ~= '' then iconSpan:tag('span'):addClass('wiki-button-emoji'):wikitext(icon) end button:tag('span'):addClass('wiki-button-label'):wikitext(label) return tostring(html) end return p
此页面嵌入的页面:
Module:按钮/doc
(
查看源代码
)
返回
Module:按钮
。
查看“︁Module:按钮”︁的源代码
来自久远澪Wiki