Modul:Development: Unterschied zwischen den Versionen

fix local htmlAndWikitextDump()
Keine Bearbeitungszusammenfassung
(fix local htmlAndWikitextDump())
 
(22 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 4: Zeile 4:
local args = ""
local args = ""
for key, value in pairs(mw.getCurrentFrame():getParent().args) do
for key, value in pairs(mw.getCurrentFrame():getParent().args) do
args = args .. "|" .. key .. "=" .. value
args = args .. "|" .. key .. "=" .. p.htmlAndWikitextDump(value)
end
end
     return "<br><code><nowiki>{{" .. mw.getCurrentFrame():getParent():getTitle() .. args .. "}}</nowiki></code><br>"
     return "<br><code><nowiki>{{" .. mw.getCurrentFrame():getParent():getTitle() .. args .. "}}</nowiki></code><br>"
Zeile 22: Zeile 22:
end
end


function p.nowiki(frame)
function p.GetFrameAndParentArgs(frame)
local m = require("Module:" .. frame.args["_module_"])
-- mw.log("GetFrameAndParentArgs(frame)")
local f = tofunction ( frame.args["_function_"] )
-- mw.logObject(frame)
return "<nowiki>" .. f(frame) .. "</nowiki>"
-- Konsolenzeile zum Debuggen:
-- p.GetParentArgs{pargs={test=14}}
local pargs
if frame.pargs ~= nil then
pargs = frame.pargs -- for debugging purposes in console
frame = mw.getCurrentFrame()
else
pargs = frame:getParent().args
end
-- mw.logObject(frame)
-- mw.logObject(pargs)
return frame, pargs
end
 
function p.htmlAndWikitextDump(t)
local d = ""
for i = 1, mw.ustring.len(t) do
local c = mw.ustring.byte(t, i)
if c == mw.ustring.byte("[") then
d = d .. "&#91;"
elseif c == mw.ustring.byte("]") then
d = d .. "&#93;"
elseif c == mw.ustring.byte("{") then
d = d .. "&#123;"
elseif c == mw.ustring.byte("}") then
d = d .. "&#125;"
elseif c == mw.ustring.byte("<") then
d = d .. "&lt;"
elseif c == mw.ustring.byte(">") then
d = d .. "&gt;"
else
d = d .. mw.ustring.char(c)
end
end
return d
end
end


return p
return p