Modul:Common: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(6 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
local p = {} | local p = {} | ||
− | function p.AttributeTable( args ) | + | function p.AttributeTable(args) |
+ | -- Draws a simple Table that contains all arguments that are fed from the | ||
+ | -- template to the scribunto-model. For debugging only! | ||
t='<table class="wikitable">' | t='<table class="wikitable">' | ||
− | for i,v in pairs(args) do | + | for i, v in pairs(args) do |
− | t = t .. '<tr><td>[[ | + | t = t .. '<tr><td>[[Attribut:' .. i .. '|' .. i .. ']]</td>' .. |
+ | '<td>' .. v .. '</td></tr>' | ||
end | end | ||
t = t .. '</table>' | t = t .. '</table>' | ||
Zeile 12: | Zeile 15: | ||
function isEmpty(a) | function isEmpty(a) | ||
return a == '' or a == nil | return a == '' or a == nil | ||
+ | end | ||
+ | |||
+ | function isInteger(str) | ||
+ | return not (str == "" or str:find("%D")) | ||
+ | end | ||
+ | |||
+ | function get_key_for_value( t, value ) | ||
+ | for k,v in pairs(t) do | ||
+ | if v==value then return k end | ||
+ | end | ||
+ | return nil | ||
+ | end | ||
+ | |||
+ | function split(s, d) | ||
+ | if d==nil then d="%s" end | ||
+ | |||
+ | arr={} | ||
+ | n=0 | ||
+ | for i in string.gmatch(s, "[^"..d.."]+") do | ||
+ | arr[n]=i | ||
+ | n=n+1 | ||
+ | end | ||
+ | return arr | ||
end | end | ||
return p | return p |
Aktuelle Version vom 9. September 2024, 16:38 Uhr
Das Commons-Modul ist ein reines Import-Modul, welches immer wieder kehrende Funktionen beinhaltet, die über das Ganze Projekt hinweg immer wieder gebraucht werden.
local p = {}
function p.AttributeTable(args)
-- Draws a simple Table that contains all arguments that are fed from the
-- template to the scribunto-model. For debugging only!
t='<table class="wikitable">'
for i, v in pairs(args) do
t = t .. '<tr><td>[[Attribut:' .. i .. '|' .. i .. ']]</td>' ..
'<td>' .. v .. '</td></tr>'
end
t = t .. '</table>'
return t
end
function isEmpty(a)
return a == '' or a == nil
end
function isInteger(str)
return not (str == "" or str:find("%D"))
end
function get_key_for_value( t, value )
for k,v in pairs(t) do
if v==value then return k end
end
return nil
end
function split(s, d)
if d==nil then d="%s" end
arr={}
n=0
for i in string.gmatch(s, "[^"..d.."]+") do
arr[n]=i
n=n+1
end
return arr
end
return p