Module:Direct link

Revision as of 22:41, 31 October 2024 by Selfice (talk | contribs) (创建页面,内容为“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 return '<span class="plainlinks">[' .. mw.title.new( page ):fullUrl() .. ' ' .. text .. ']</span>' end function p.main( f ) local args = f local frame = mw.getCurrentFrame() if f == frame then…”)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

此模块用于实现{{Direct link}}。


en:Module:Direct link



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
	
	return '<span class="plainlinks">[' .. mw.title.new( page ):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