Difference between revisions of "Module:Sandbox"

From Yugipedia
Jump to: navigation, search
(Saving some set list tests here, but keep the same functional content.)
(Just to test lazy loading.)
(Tag: Replaced)
Line 3: Line 3:
 
--  For testing purposes
 
--  For testing purposes
 
------------------------
 
------------------------
 
local function pre( c )
 
return tostring(
 
mw.html.create( 'pre' ):wikitext( c ):done()
 
);
 
end
 
  
 
return {
 
return {
['test args'] = function( frame )
+
  Util = function()
local ret = {}
+
    return require( 'Module:Util' )
 
+
  end,
for i, v in ipairs( frame.args ) do
+
  Data = function()
table.insert( ret, '# ' .. v )
+
    return require( 'Module:Data' )
end
+
  end,
 
 
return table.concat( ret, '\n' )
 
end,
 
 
 
main = function( frame )
 
return tostring(
 
mw.html.create( 'table' )
 
:addClass( 'wikitable' )
 
:tag( 'tr' )
 
:tag( 'th' ):wikitext( 'frame' ):done()
 
:tag( 'td' ):node( pre( mw.dumpObject( frame ) ) ):done()
 
:done()
 
:tag( 'tr' )
 
:tag( 'th' ):wikitext( 'parent frame' ):done()
 
:tag( 'td' ):node( pre( mw.dumpObject( frame:getParent() ) ) ):done()
 
:done()
 
:tag( 'tr' )
 
:tag( 'th' ):wikitext( 'current frame' ):done()
 
:tag( 'td' ):node( pre( mw.dumpObject( mw.getCurrentFrame() ) ) ):done()
 
:done()
 
:done()
 
);
 
end
 
 
}
 
}
 
 
-- Some set list tests.
 
-- Just copy to the console.
 
 
--[=[
 
--[===[
 
Row test:
 
]===]
 
local DATA = require( 'Module:Data' )
 
 
local Row = require( 'Module:Set list/Row' )
 
local Renderer = require( 'Module:Set list/Renderer' )
 
 
local lnEnglish = DATA.getLanguage( 'en' )
 
local row = Row(
 
'ABCD-EN123',
 
'Some name',
 
{
 
DATA.getRarity( 'R' ),
 
DATA.getRarity( 'ScR' ),
 
DATA.getRarity( 'UtR' ),
 
},
 
{
 
{
 
name = 'Volume',
 
key = 'volume',
 
value = '[[Yu-Gi-Oh! ZEXAL Volume 1 promotional card|Volume 1]]',
 
},
 
{
 
name = 'Col with Spaces',
 
key = '??',
 
value = 'How to handle spaces for the key?',
 
},
 
},
 
setmetatable(
 
{
 
quantity = '1',
 
},
 
{
 
__index = {
 
['print'] = 'Reprint',
 
}
 
}
 
)
 
)
 
local renderer = Renderer( lnEnglish )
 
 
mw.log(
 
row:render( renderer )
 
)
 
 
mw.logObject( renderer )
 
--]=]
 
 
--[=[
 
--[===[
 
CardList test:
 
]===]
 
local DATA = require( 'Module:Data' )
 
 
local Row = require( 'Module:Set list/Row' )
 
local CardList = require( 'Module:Set list/CardList' )
 
local Renderer = require( 'Module:Set list/Renderer' )
 
 
local lnEnglish = DATA.getLanguage( 'en' )
 
 
local cardList = CardList(
 
'Test header',
 
{
 
DATA.getRarity( 'R' ),
 
DATA.getRarity( 'ScR' ),
 
DATA.getRarity( 'UtR' ),
 
length = 3,
 
},
 
{
 
{
 
name = 'Volume',
 
key = 'volume',
 
},
 
{
 
name = 'Col with Spaces',
 
key = '??',
 
},
 
},
 
{
 
quantity = '2',
 
['print'] = 'Reprint',
 
}
 
)
 
cardList
 
:addRow(
 
'ABCD-EN123',
 
'Some name',
 
{
 
DATA.getRarity( 'C' ),
 
length = 1,
 
},
 
{
 
{
 
name = 'Volume',
 
key = 'volume',
 
value = '[[Yu-Gi-Oh! ZEXAL Volume 1 promotional card|Volume 1]]',
 
},
 
{
 
name = 'Col with Spaces',
 
key = '??',
 
value = 'How to handle spaces for the key?',
 
},
 
},
 
{
 
quantity = '1',
 
}
 
)
 
:addRow(
 
'EFGH-EN456',
 
'Some name 2',
 
{
 
length = 0,
 
},
 
{
 
{
 
name = 'Volume',
 
key = 'volume',
 
value = '[[Yu-Gi-Oh! ZEXAL Volume 2 promotional card|Volume 2]]',
 
},
 
{
 
name = 'Col with Spaces',
 
key = '??',
 
value = 'How to handle spaces for the key? 2',
 
},
 
},
 
{
 
['print'] = 'Reprint in EU only',
 
}
 
)
 
local renderer = Renderer( lnEnglish )
 
 
mw.log(
 
cardList:render( renderer )
 
)
 
 
mw.logObject( renderer )
 
--]=]
 

Revision as of 01:26, 29 October 2019

------------------------
--  Sandbox module:
--  For testing purposes
------------------------

return {
  Util = function()
    return require( 'Module:Util' )
  end,
  Data = function()
    return require( 'Module:Data' )
  end,
}