Wir laden dich herzlich auf den Star Citizen Wiki Discord Server ein! Du kannst uns auch auf unserem neuen YouTube-Chanel finden!
Modul:Sandbox
From Star Citizen Wiki
Views
Actions
Namespaces
Variants
Tools
Modulinfo
Dies ist eine Spielumgebung.
Dieses Modul kann frei für Testzwecke verwendet werden.
Du kannst den Code dieser Seite jederzeit löschen.
local For = {}
local metatable = {}
local methodtable = {}
metatable.__index = methodtable
--- Format the arguments to text
---
--- @return string
function methodtable.format( self )
if type( self.args ) ~= 'table' then
return
end
local title = self.args[ 2 ] or self.args[ 'Titel' ] or nil
local text = self.args[ 1 ] or self.args[ 'Text' ] or nil
if title == nil or text == nil then
return
end
text = string.format( 'Für %s', text )
title = mw.text.split( title, '#', true )
local queryPart = nil
if #title > 1 then
queryPart = title[ 2 ]
title = title[ 1 ]
end
title = mw.title.new( self.args[ 2 ] or self.args[ 'Titel' ] )
if title == nil then
return
end
local icon = nil
if string.match( text, 'alle ' ) ~= nil or string.match( text, 'mehr Informationen' ) ~= nil then
icon = mw.html.create( 'span' ):addClass( 'icon-redirect' ):allDone()
end
local linkText = title.text
if title.namespace ~= 0 then
linkText = string.format( '%s:%s', title.nsText, title.text )
else
linkText = string.format( 'Seite %s', linkText )
end
local href = title:localUrl()
if queryPart ~= nil then
href = href .. '#' .. queryPart
linkText = string.format( '%s § %s', linkText, queryPart )
end
linkText = string.format( '%s siehe [[%s|%s]]', text, href, linkText )
local out = mw.html.create( 'span' )
:addClass( 'for-link' )
:node( icon )
:wikitext( linkText )
return tostring( out:allDone() )
end
--- Entry point for template calls
--- @return string
function For.fromArgs( frame )
if frame == nil then
return
end
local instance = For:new( frame )
return instance:format()
end
--- New Instance
--- Library entrance
function For.new( self, frame )
local instance = {
args = require( 'Module:Arguments' ).getArgs( frame ),
}
setmetatable( instance, metatable )
return instance
end
return For