알려진 문제
순환 참조가 발생했을 시 ?action=edit
으로 내용을 변경하기 전까지 문서 로딩이 되지 않습니다.
local p = {}
local function argumentCount(frame) --frame.args의 원수 수를 세어서 반환하는 함수, --더 쉬운 방법이 있다면 알려주세요.
local count = 0
for i,v in frame:argumentPairs() do
count = count+1
end
return count
end
function p.category(frame)
local argc = argumentCount(frame)
if argc % 2 ~= 0 then return "매개변수가 짝이 맞지 않습니다." end
selfCategory = frame.args[1] .. "/" .. frame.args[2]
local text = ""
if (mw.title.getCurrentTitle().text ~= frame.args[1] .. "/" .. frame.args[2]) then
text = text .. "[[분류:" .. selfCategory .. "]]"
end
for i=1,(argc-2)/2 do
if mw.title.new("틀:" .. frame.args[(i*2)+1] .. "/" .. frame.args[(i*2)+2] .. " 분류").exists then
text = text .. frame:expandTemplate{ title = frame.args[(i*2)+1] .. "/" .. frame.args[(i*2)+2] .. " 분류"}
else
text = text .. "[[분류:" .. frame.args[(i*2)+1] .. "/" .. frame.args[(i*2)+2] .. "]]"
end
end
end
function p.document(frame)
local argc = argumentCount(frame)
if argc % 2 ~= 0 then return "매개변수가 짝이 맞지 않습니다." end
selfCategory = frame.args[1] .. "/" .. frame.args[2]
local text = ""
text = text .. "* [[:분류:" .. selfCategory .. "]]\n"
for i=1,(argc-2)/2 do
text = text .. "* [[:분류:" .. frame.args[(i*2)+1] .. "/" .. frame.args[(i*2)+2] .. "]]\n"
end
return text
end
return p