Módulo:Book: diferenças entre revisões

[edição verificada][edição verificada]
Conteúdo apagado Conteúdo adicionado
Desfez a edição 269240 de Helder.wiki (Discussão) + if not value then return nil end
Uso de getArgs nas funções que implementam a Predefinição:NOMEDOLIVRO, a Predefinição:NOMEDOCAPÍTULO e a Predefinição:EXISTBASEPAGENAME; simplificação
Linha 1:
local getArgs = require('Module:Arguments').getArgs
local collectionPrefix = 'Wikilivros:Livros/'
 
local arraySearch = function ( needle, haystack )
for k,v in pairs( haystack ) do
Linha 9 ⟶ 10:
return result;
end
 
local function getArgNums(args)
-- Returns an array containing the keys of all positional arguments that contain data (i.e. non-whitespace values).
Linha 21 ⟶ 23:
end
 
-- [[Predefinição:NOMEDOLIVRO]]
local getBookName = function ( page )
page = page or mw.title.getCurrentTitle().text
Linha 26 ⟶ 29:
if pos == nil then
return page
else
return mw.ustring.sub( page, 1, pos - 1 )
end
return mw.ustring.sub( page, 1, pos - 1 )
end
 
-- [[Predefinição:NOMEDOCAPÍTULO]]
local getChapterName = function ( page )
page = page or mw.title.getCurrentTitle().text
Linha 36 ⟶ 39:
if pos == nil then
return ''
else
return mw.ustring.sub( page, pos + 1 )
end
return mw.ustring.sub( page, pos + 1 )
end
 
Linha 243 ⟶ 245:
_core = core,
getBookName = function( frame )
returnlocal getBookNameargs = getArgs( frame.args[1] )
return getBookName( args[1] )
end,
getChapterName = function( frame )
returnlocal getChapterNameargs = getArgs( frame.args[1] )
return getChapterName( args[1] )
end,
getExistingBasePageName = function( frame )
returnlocal getExistingBasePageNameargs = getArgs( frame.args[1] )
return getExistingBasePageName( args[1] )
end,
getPrintableVersion = function( frame )