모듈:Linkwithtemplate: 두 판 사이의 차이

큰숲백과, 나무를 보지 말고 큰 숲을 보라.
(새 문서: local p = {} p.test = function(frame) local args = require('Module:Arguments').getArgs(frame) local doc = args[1] or '' local linkname = args[2] or nil local class = args['class'] or '' if mw.title.new(doc).exists then if linkname then return ''..linkname..'' else return ''..doc..'' end else if linkname == nil then linkname = doc end return '<span class="plainlinks new '..class..'">['..mw.site.server..'/index.php?'.. mw.uri.build...)
 
편집 요약 없음
 
(같은 사용자의 중간 판 4개는 보이지 않습니다)
1번째 줄: 1번째 줄:
local p = {}
local p = {}


p.test = function(frame)
p.makelink = function(article, linkname, preload, editintro, class)
local args = require('Module:Arguments').getArgs(frame)
    if mw.title.new(article).exists then
local doc = args[1] or ''
        return '[[' .. article .. (linkname and '|' .. linkname or '') .. ']]'
local linkname = args[2] or nil
    else
local class = args['class'] or ''
        return string.format('<span class="plainlinks new %s">[%s%s/index.php?%s %s]</span>',
            class or '',
            mw.site.server,
            mw.site.scriptPath,
            mw.uri.buildQueryString {
                action = 'edit',
                title = article, editintro = editintro, preload = preload
            },
            linkname)
    end
end


if mw.title.new(doc).exists then
p.main = function(frame)
if linkname then
    local args = require('Module:Arguments').getArgs(frame)
return '[['..doc..'|'..linkname..']]'
 
else
    return p.makelink(args[1] or '', args[2] or args[1], args['preload'], args['editintro'], args['class'] or '')
return '[['..doc..']]'
end
else
if linkname == nil then
linkname = doc
end
return '<span class="plainlinks new '..class..'">['..mw.site.server..'/index.php?'..
mw.uri.buildQueryString {
    action = 'edit',
preload = args['템플릿'],
    editintro = args['editintro'],
    title = doc
}..' '..linkname..']</span>'
end
end
end
------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
return p
return p

2025년 1월 30일 (목) 18:35 기준 최신판

local p = {}

p.makelink = function(article, linkname, preload, editintro, class)
    if mw.title.new(article).exists then
        return '[[' .. article .. (linkname and '|' .. linkname or '') .. ']]'
    else
        return string.format('<span class="plainlinks new %s">[%s%s/index.php?%s %s]</span>',
            class or '',
            mw.site.server,
            mw.site.scriptPath,
            mw.uri.buildQueryString {
                 action = 'edit', 
                title = article, editintro = editintro, preload = preload
            },
            linkname)
    end
end

p.main = function(frame)
    local args = require('Module:Arguments').getArgs(frame)

    return p.makelink(args[1] or '', args[2] or args[1], args['preload'], args['editintro'], args['class'] or '')
end
------------------------------------------------------------------------------------
return p