Модуль:Unsubst: различия между версиями

Перейти к навигации Перейти к поиску
м
1 версия импортирована
(sync from sandbox; see talk;)
м (1 версия импортирована)
 
(не показана 1 промежуточная версия этого же участника)
Строка 9: Строка 9:
['$aliases'] = 'parameter aliases',
['$aliases'] = 'parameter aliases',
['$flags'] = 'flags',
['$flags'] = 'flags',
['$B'] = 'template content',
['$format'] = 'date format',
['$template-name'] = 'template invocation name override',
['$B'] = 'template content'
}
}


Строка 48: Строка 48:
-- Find the invocation name.
-- Find the invocation name.
local mTemplateInvocation = require('Module:Template invocation')
local mTemplateInvocation = require('Module:Template invocation')
local name
local name = mTemplateInvocation.name(frame:getParent():getTitle())
 
if frame.args['$template-name'] and '' ~= frame.args['$template-name'] then
name = frame.args['$template-name'] -- override whatever the template name is with this name
else
name = mTemplateInvocation.name(frame:getParent():getTitle())
end


-- Combine passed args with passed defaults
-- Combine passed args with passed defaults
local args = {}
local args = {}
local format = frame.args['$format'] or 'j xg Y'
if string.find( ','..(frame.args['$flags'] or '')..',', ',%s*override%s*,' ) then
if string.find( ','..(frame.args['$flags'] or '')..',', ',%s*override%s*,' ) then
for k, v in pairs( frame:getParent().args ) do
for k, v in pairs( frame:getParent().args ) do
Строка 65: Строка 60:
if not specialParams[k] then
if not specialParams[k] then
if v == '__DATE__' then
if v == '__DATE__' then
v = mw.getContentLanguage():formatDate( 'F Y' )
v = mw.getContentLanguage():formatDate( format )
end
end
args[k] = v
args[k] = v
Строка 74: Строка 69:
if not specialParams[k] then
if not specialParams[k] then
if v == '__DATE__' then
if v == '__DATE__' then
v = mw.getContentLanguage():formatDate( 'F Y' )
v = mw.getContentLanguage():formatDate( format )
end
end
args[k] = v
args[k] = v

Навигация