„Modul:Data/CH-AG“ – Versionsunterschied
Erscheinungsbild
[gesichtete Version] | [gesichtete Version] |
Inhalt gelöscht Inhalt hinzugefügt
noch ohne Funktion mit Frame-Argument |
Implementierung von selectionError und invokeData (mit Frame-Argument) |
||
Zeile 8: | Zeile 8: | ||
tArgs.selection = ({ |
tArgs.selection = ({ |
||
["Auswahl von Gemeindedaten"] = 1, |
["Auswahl von Gemeindedaten"] = 1, |
||
})[tArgs.selectionName] or tArgs.selection |
})[tArgs.selectionName] or tonumber(tArgs.selection) |
||
if tArgs.selection then |
if tArgs.selection then |
||
local b, tSub = pcall(require, "Module:Data/CH-AG/" .. tArgs.selection) |
local b, tSub = pcall(require, "Module:Data/CH-AG/" .. tArgs.selection) |
||
Zeile 15: | Zeile 15: | ||
return tSub.getData(tArgs) |
return tSub.getData(tArgs) |
||
else |
else |
||
tArgs.selectionError = tArgs.selectionError or "[[Module:Data/CH-AG/" .. tArgs.selection .."]].getData" |
|||
return tArgs.selectionError |
|||
end |
end |
||
else |
else |
||
tArgs.selectionError = tArgs.selectionError or "[[Module:Data/CH-AG/" .. tArgs.selection .."]]" |
|||
return tArgs.selectionError |
|||
end |
end |
||
else |
else |
||
tArgs.selectionError = tArgs.selectionError or '<span class="error">selection = ""</span>' |
|||
return tArgs.selectionError |
|||
end |
end |
||
else |
else |
||
return '<span class="error">tArgs = {}</span>' |
return '<span class="error">tArgs = {}</span>' |
||
end |
end |
||
end |
|||
function p.invokeData(frame) |
|||
local t = {} |
|||
t.selection = frame.args[1] or frame.args["selection"] |
|||
t.selectionName = frame.args["selectionName"] |
|||
t.selectionError = frame.args["selectionError"] or "" |
|||
t.version = frame.args[2] or frame.args["version"] |
|||
t.versionDate = frame.args["versionDate"] |
|||
t.versionError = frame.args["versionError"] or "" |
|||
t.key = frame.args[3] or frame.args["key"] |
|||
t.keyError = frame.args["keyError"] or "" |
|||
t.field = frame.args[4] or frame.args["field"] |
|||
t.fieldError = frame.args["fieldError"] or "" |
|||
return p.getData(t) |
|||
end |
end |
||
Version vom 6. September 2016, 23:05 Uhr
Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | ||
Modul | Deutsch
|
Modul: | Dokumentation |
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
local p = {}
function p.getData(tArgs)
if type(tArgs) == type({}) then
if not tonumber(tArgs.selection) then
tArgs.selectionName = tArgs.selection
end
tArgs.selection = ({
["Auswahl von Gemeindedaten"] = 1,
})[tArgs.selectionName] or tonumber(tArgs.selection)
if tArgs.selection then
local b, tSub = pcall(require, "Module:Data/CH-AG/" .. tArgs.selection)
if type(tSub) == type({}) then
if tSub.getData then
return tSub.getData(tArgs)
else
tArgs.selectionError = tArgs.selectionError or "[[Module:Data/CH-AG/" .. tArgs.selection .."]].getData"
return tArgs.selectionError
end
else
tArgs.selectionError = tArgs.selectionError or "[[Module:Data/CH-AG/" .. tArgs.selection .."]]"
return tArgs.selectionError
end
else
tArgs.selectionError = tArgs.selectionError or '<span class="error">selection = ""</span>'
return tArgs.selectionError
end
else
return '<span class="error">tArgs = {}</span>'
end
end
function p.invokeData(frame)
local t = {}
t.selection = frame.args[1] or frame.args["selection"]
t.selectionName = frame.args["selectionName"]
t.selectionError = frame.args["selectionError"] or ""
t.version = frame.args[2] or frame.args["version"]
t.versionDate = frame.args["versionDate"]
t.versionError = frame.args["versionError"] or ""
t.key = frame.args[3] or frame.args["key"]
t.keyError = frame.args["keyError"] or ""
t.field = frame.args[4] or frame.args["field"]
t.fieldError = frame.args["fieldError"] or ""
return p.getData(t)
end
return p