Изменения

Перейти к навигации Перейти к поиску
+поддержка таблиц
Строка 29: Строка 29:  
getArgs = require('Module:Arguments').getArgs
 
getArgs = require('Module:Arguments').getArgs
 
end
 
end
local trim = require('Module:Yesno')(frame:getParent().args._trim, false) or false --чтобы не было nil
+
local trim = not (require('Module:Yesno')(frame:getParent().args._trim, false) == false) --по умолчанию true
local args = copy(getArgs(frame, {trim = _trim, removeBlanks = false})) --copy(frame.args)
+
local args = copy(getArgs(frame, {trim = trim, removeBlanks = false})) --copy(frame.args)
 
local tname = args._template or args[1]
 
local tname = args._template or args[1]
 
local opener = args._opener or '* '
 
local opener = args._opener or '* '
 
local sep = args._sep
 
local sep = args._sep
 
local style = args._style
 
local style = args._style
 +
local pre_text = args['_pre-text'] or args._prefix or ''
 +
local post_text = args['_post-text'] or args._postfix or ''
 +
if (style == 'wikitable') then
 +
opener = '|-\n| '
 +
end
 
 
 
if tname == '' or tname == nil then --при опущенном первом параметре берём имя шаблона из названия страницы
 
if tname == '' or tname == nil then --при опущенном первом параметре берём имя шаблона из названия страницы
Строка 44: Строка 49:  
 
 
local targs, content = {}, ''
 
local targs, content = {}, ''
 +
if (style == 'wikitable') then
 +
content = '{| class="wikitable"\n! Код !! Результат\n'
 +
end
 
for k, v in pairs(args) do
 
for k, v in pairs(args) do
 
if type(k) == 'number' then
 
if type(k) == 'number' then
 
targs = mw.text.split(v, '\\')
 
targs = mw.text.split(v, '\\')
 
table.insert(targs, 1, tname)
 
table.insert(targs, 1, tname)
targs._sep, targs._style = sep, style
+
targs._sep, targs._style, targs['_pre-text'], targs['_post-text'] = sep, style, pre_text, post_text
 
content = content .. opener .. tostring(expand(frame, 'пример', targs)) .. '\n'
 
content = content .. opener .. tostring(expand(frame, 'пример', targs)) .. '\n'
 
end
 
end
 +
end
 +
if (style == 'wikitable') then
 +
content = content .. '|}'
 +
else
 +
content = content:sub(1, -2)
 
end
 
end
 
 
return string.sub(content, 1, -2)
+
return content
 
end
 
end
    
return p
 
return p
Анонимный участник

Реклама:

Навигация