Modul:FAQ
Die Dokumentation für dieses Modul kann unter Modul:FAQ/Doku erstellt werden
local p = {}; function tablelength(T) local count = 0 for _ in pairs(T) do count = count + 1 end return count end p.faq = function( frame ) local argv = mw.getCurrentFrame():getParent().args local faqHtml = '' local max = tablelength(argv) - 1 for i = 1, max, 2 do faqHtml = faqHtml .. '<h4 class="faq-q">' .. argv[i] .. '</h4>' faqHtml = faqHtml .. '<p class="faq-a">' .. argv[i + 1] .. '</p>' end return faqHtml end p.faqSchema = function( frame ) local faqData = '[' local argv = mw.getCurrentFrame():getParent().args local max = tablelength(argv) - 1 for i = 1, max, 2 do local item = '{ "frage": "' .. argv[i] .. '", "antwort": "' .. argv[i + 1] .. '"}' if i < max then item = item .. ',' end faqData = faqData .. item end faqData = faqData .. ']' return faqData end return p