모듈:Mfunctions 문서 원본 보기
보이기
문서 편집 권한이 없습니다. 다음 이유를 확인해주세요:
문서의 원본을 보거나 복사할 수 있습니다.
local p, FuncTable = {}, {}
function FuncTable:parse(text)
text = mw.text.decode(mw.text.unstripNoWiki(text)) -- <nowiki> 해제
local pi, fi = 1, 1 -- 처리 위치 초기화
-- 변수 처리
while text:find('{{%b{}}}', pi) do
local pos, param = text:find('{{%b{}}}', pi), text:match('{{%b{}}}', pi) -- 현재 처리 위치, 호출 문법 기억
local inner = param:sub(4, -4) -- 대괄호 제거
inner = inner:find('{%b{}}') and self:parse(inner) or inner -- 대괄호 내부 파싱 (재귀함수)
local name = inner:find('|') and inner:sub(1, inner:find('|') - 1) or inner -- 변수명
local default = inner:find('|') and inner:sub(inner:find('|') + 1) -- 입력된 변수가 없을 때 대신 표시되는 기본값
local parent = mw.getCurrentFrame():getParent() -- 이 함수를 실행하는 모듈이 호출된 틀의 프레임
local result = parent and parent.args[name] or default or param -- 출력값
pi = pos + #param -- 처리 위치 넘기기
text = text:sub(1, pos - 1) .. result .. text:sub(pi) -- 덮어쓰기
end
-- 함수 처리
while text:find('{%b{}}', fi) do
local pos, func = text:find('{%b{}}', fi), text:match('{%b{}}', fi) -- 현재 처리 위치, 호출 문법 기억
000
1:0
이 문서에서 사용한 틀:
- 틀:틀 설명문서 (원본 보기)
- 모듈:Arguments (원본 보기)
- 모듈:Category handler (원본 보기) (준보호됨)
- 모듈:Category handler/blacklist (원본 보기)
- 모듈:Category handler/config (원본 보기)
- 모듈:Category handler/data (원본 보기)
- 모듈:Category handler/shared (원본 보기)
- 모듈:Documentation (원본 보기)
- 모듈:Documentation/config (원본 보기)
- 모듈:Message box (원본 보기)
- 모듈:Message box/configuration (원본 보기)
- 모듈:Message box/localize (원본 보기)
- 모듈:Mfunctions/설명문서 (원본 보기)
- 모듈:Namespace detect/config (원본 보기)
- 모듈:Namespace detect/data (원본 보기)
- 모듈:No globals (원본 보기)
- 모듈:Yesno (원본 보기)
모듈:Mfunctions 문서로 돌아갑니다.