Modul:Development: Unterschied zwischen den Versionen

fix local htmlAndWikitextDump()
Keine Bearbeitungszusammenfassung
(fix local htmlAndWikitextDump())
 
(15 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 20: Zeile 20:
end
end
     return "<br><code><nowiki>(" .. args .. ")</nowiki></code><br>"
     return "<br><code><nowiki>(" .. args .. ")</nowiki></code><br>"
end
function p.GetFrameAndParentArgs(frame)
-- mw.log("GetFrameAndParentArgs(frame)")
-- mw.logObject(frame)
-- 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