Немає опису редагування |
Немає опису редагування |
||
| Рядок 61: | Рядок 61: | ||
infobox:renderSection( { | infobox:renderSection( { | ||
title = self.frameArgs["назывка"], | title = self.frameArgs["назывка"], | ||
subtitle = self.frameArgs[" | subtitle = self.frameArgs["тіп"], | ||
content = table.concat( sectionTable ) | content = table.concat( sectionTable ) | ||
} ) | } ) | ||
Ревізія 02:24, 18 октовбра 2023
Документацію для цього модуля можна створити у Модуль:Village/документація
require( 'strict' )
local Village = {}
local metatable = {}
local methodtable = {}
metatable.__index = methodtable
local common = require( 'Module:Common' )
local hatnote = require( 'Module:Hatnote' )._hatnote
--- Set the frame and load args
--- @param frame table
function methodtable.setFrame( self, frame )
self.currentFrame = frame
self.frameArgs = require( 'Module:Arguments' ).getArgs( frame )
end
--- Create the infobox
function methodtable.getInfobox( self, frame )
local infobox = require( 'Module:InfoboxNeue' ):new( {
placeholderImage = ''
} )
local tabber = require( 'Module:Tabber' ).renderTabber
sectionTable = {
infobox:renderItem( {
label = 'Населеня',
data = self.frameArgs["населеня"],
row = true,
spacebetween = true
} ),
infobox:renderItem( {
label = 'Коордінаты',
data = self.frameArgs["коордінаты"],
row = true,
spacebetween = true
} ),
infobox:renderItem( {
label = 'Природна зона',
data = self.frameArgs["природна зона"],
row = true,
spacebetween = true
} ),
infobox:renderItem( {
label = 'Закладеноє',
data = self.frameArgs["закладеноє"],
row = true,
spacebetween = true
} ),
infobox:renderItem( {
label = 'Голова',
data = self.frameArgs["голова"],
row = true,
spacebetween = true
} )
}
-- Create section with items
infobox:renderSection( {
title = self.frameArgs["назывка"],
subtitle = self.frameArgs["тіп"],
content = table.concat( sectionTable )
} )
end
--- New Instance
function Village.new( self )
local instance = {
categories = {}
}
setmetatable( instance, metatable )
return instance
end
--- Generates an infobox based on passed frame args and SMW data
---
--- @param frame table Invocation frame
--- @return string
function Village.infobox( frame )
local instance = Village:new()
instance:setFrame( frame )
local debugOutput = ''
if instance.frameArgs[ 'debug' ] ~= nil then
debugOutput = instance:makeDebugOutput()
end
return tostring( instance:getInfobox() ) .. debugOutput
end
--- "Main" entry point for templates that saves the API Data and outputs the infobox
---
--- @param frame table Invocation frame
--- @return string
function Village.main( frame )
local instance = Village:new()
instance:setFrame( frame )
local debugOutput = ''
if instance.frameArgs[ 'debug' ] ~= nil then
debugOutput = instance:makeDebugOutput()
end
local infobox = tostring( instance:getInfobox() )
return infobox .. debugOutput .. table.concat( instance.categories )
end
return Village