跳转到内容

模块:Direct link:修订间差异

来自TPC
Harry00025留言 | 贡献
创建页面,内容为“local p = {} function p.call( inputArgs ) if not inputArgs or type( inputArgs ) ~= 'table' then return nil end local page = inputArgs[ 1 ] or '' local text = inputArgs[ 2 ] or '' if page == '' then return '' end if text == '' then text = page end local linkTargetObject = mw.title.new( page ) if not linkTargetObject then return '' end return '<span class="plainlinks">[' .. linkTargetObject:fullUrl() .. ' ' .. text .. ']</span>' end fun…”
 
Harry00025留言 | 贡献
Harry00025移动页面模块:Direct Llink模块:Direct link
 
(未显示同一用户的1个中间版本)
(没有差异)

2026年5月28日 (四) 06:05的最新版本

此模块的文档可以在模块:Direct link/doc创建

local p = {}

function p.call( inputArgs )
	if not inputArgs or type( inputArgs ) ~= 'table' then
		return nil
	end

	local page = inputArgs[ 1 ] or ''
	local text = inputArgs[ 2 ] or ''

	if page == '' then
		return ''
	end

	if text == '' then
		text = page
	end

	local linkTargetObject = mw.title.new( page )
	if not linkTargetObject then
		return ''
	end

	return '<span class="plainlinks">[' .. linkTargetObject:fullUrl() .. ' ' .. text .. ']</span>'
end

function p.main( f )
	local args = f
	local frame = mw.getCurrentFrame()
	if f == frame then
		args = require( 'Module:ProcessArgs' ).merge( true )
	end

	return p.call{ args[ 1 ] or '', args[ 2 ] or '' }
end

return p