모듈:인터위키: 두 판 사이의 차이
보이기
잔글 소스 수정 실수 |
편집 요약 없음 |
||
| 29번째 줄: | 29번째 줄: | ||
function p._replace(text, to_be_replaced, replace_with) | function p._replace(text, to_be_replaced, replace_with) | ||
local strFindStart, strFindEnd = | local strFindStart, strFindEnd = ustring.find(text, to_be_replaced) | ||
local retText | local retText | ||
if strFindStart ~= nil then | if strFindStart ~= nil then | ||
local nStringCnt = string.len(text) | local nStringCnt = string.len(text) | ||
local retText = | local retText = ustring.sub(text, 1, strFindStart-1) .. replace_with .. ustring.sub(text, strFindEnd+1, nStringCnt) | ||
else | else | ||
retText = text | retText = text | ||
2021년 10월 25일 (월) 23:27 판
{{#css: .template-documentation {
clear: both; margin: 1em 0 0 0; padding: 1em
} /* 아래 상자 */ .mbox-text {
clear: both; background-color: #e8ffe8;
}
.template-documentation-template-data .mw-templatedata-doc-desc {
display: none;
}
}}
사용방법
{{#invoke:인터위키|wiki|(위키명)|(언어명)|(문서명)|(표현명)}}
Lua 오류: bad argument #1 to 'find' (string expected, got nil).위 설명은 모듈:인터위키/설명문서의 내용을 가져와 보여주고 있습니다.
연습장이나 사용자 문서에서 틀의 사용이나 수정을 연습할 수 있습니다.
local getArgs = require('Module:Arguments').getArgs
local ustring = mw.ustring
local wikiData = mw.loadData('Module:인터위키/data')
local p = {}
--[[
{{#invoke:wiki|(wiki name)|(codename)|(article)|(outer text)}}
]]
function p.wiki(frame)
if wikiData[frame.args[1]]~=nil then
local baseText = wikiData[frame.args[1]]
baseText = p._replace(baseText, '$1', frame.args[2])
baseText = p._replace(baseText, '$2', frame.args[3])
local exText = ''
if frame.args[4]~=nil then
exText = frame.args[4]
else
exText = frame.args[3]
end
return '<span class="plainlinks">['..baseText..' '..exText..']</span>'
end
end
function p._replace(text, to_be_replaced, replace_with)
local strFindStart, strFindEnd = ustring.find(text, to_be_replaced)
local retText
if strFindStart ~= nil then
local nStringCnt = string.len(text)
local retText = ustring.sub(text, 1, strFindStart-1) .. replace_with .. ustring.sub(text, strFindEnd+1, nStringCnt)
else
retText = text
end
return retText
end
return p