Difference between revisions of "Module:Sandbox"

From Yugipedia
Jump to: navigation, search
(preprocess inside pre tags.)
(Saving card table test.)
Line 3: Line 3:
 
--  For testing purposes
 
--  For testing purposes
 
------------------------
 
------------------------
 +
 +
--[[
 +
testing card table.
 +
type:
 +
p.test()
 +
in the console to test
 +
]]
 +
local ct = require 'Module:Card table' 'TEST'
  
 
return {
 
return {
--frame:preprocess(  
+
test = function()
t = function( frame ) return tostring( mw.html.create( 'pre' ):node( frame:preprocess( '<gallery>\nBack-EN.png | Test\n</gallery>\n') ):done() ) end
+
ct:Args():Header():setContent( 'hello' ):setId( 'id' )
 +
ct:Args():Image():setMain( 'IMG.png' ):setDefault( 'BACK-EN.png' ):setId( 'id-img' ):Footer():setContent( 'A cool image' )
 +
ct:Args():Rows():Add():setLabel( 'Row1 header' ):setContent( 'Row1 content' )
 +
ct:error( 'err1' ):error( 'err2' )
 +
ct:category( 'Category1' )
 +
-- Print:
 +
mw.log( "STATE:" )
 +
mw.logObject( ct )
 +
mw.log()
 +
mw.log()
 +
mw.log( "RENDER WIKITEXT WITH DEBUG:" )
 +
mw.log( ct:Render():debug():toWikitext() )
 +
mw.log()
 +
mw.log()
 +
mw.log( "RENDER WIKITEXT WITHOUT DEBUG:" )
 +
mw.log( ct:Render():toWikitext() )
 +
end
 
}
 
}

Revision as of 23:44, 18 November 2018

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

--[[
testing card table.
type:
p.test()
in the console to test
]]
local ct = require 'Module:Card table' 'TEST'

return {
	test = function()
		ct:Args():Header():setContent( 'hello' ):setId( 'id' )
		ct:Args():Image():setMain( 'IMG.png' ):setDefault( 'BACK-EN.png' ):setId( 'id-img' ):Footer():setContent( 'A cool image' )
		ct:Args():Rows():Add():setLabel( 'Row1 header' ):setContent( 'Row1 content' )
		ct:error( 'err1' ):error( 'err2' )
		ct:category( 'Category1' )
		-- Print:
		mw.log( "STATE:" )
		mw.logObject( ct )
		mw.log()
		mw.log()
		mw.log( "RENDER WIKITEXT WITH DEBUG:" )
		mw.log( ct:Render():debug():toWikitext() )
		mw.log()
		mw.log()
		mw.log( "RENDER WIKITEXT WITHOUT DEBUG:" )
		mw.log( ct:Render():toWikitext() )
	end
}