Изменения

Модуль:Значения блоков

883 байта добавлено, 17:50, 5 августа 2016
Новая страница: «local p = {} p.value = function( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Модуль:ProcessArgs' ).merge( true ) end local…»
local p = {}
p.value = function( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( 'Модуль:ProcessArgs' ).merge( true )
end
local block = mw.ustring.gsub(mw.ustring.lower(mw.text.trim( args[1] or '' )), "[_%(%)%-%s]+", '')
local type = mw.text.trim(args['тип'] or '') -- должен быть в родительном падеже

local value = mw.loadData( 'Модуль:Значения ' .. type)[block]
local category = ''
if not value then
value = '[[Шаблон:Значения ' .. type .. '#Отсутствующее значение|?]]'
local title = mw.title.getCurrentTitle()
if not args['некат'] and title.namespace == 0 and not title.isSubpage then
category = '[[Категория:Отсутствующие значения ' .. mw.ustring.lower(type) .. ']]'
end
end
return value .. category
end
return p