Module:SandboxH

-- -- SandboxH - create a simple html table using global-module -- see: http://dev.wikia.com/wiki/Global_Lua_Modules/Tablebuilder -- also: http://dev.wikia.com/wiki/Module:Devmodule -- and: http://dev.wikia.com/wiki/Lua_reference_manual/Scribunto_libraries#HTML_library

local p = {}

local tableBuilder = require("Dev:Tablebuilder") local getargs = require("Dev:Arguments").getArgs

local function testDiv local div = mw.html.create( 'div' ) div :attr( 'id', 'testdiv' ) :css( 'width', '100%' ) :wikitext( 'Some text' ) :tag( 'hr' ) return div --   return tostring( div ) -- Output: Some text end

function testTable -- Array consisting of rows and columns local tRowData = { -- Row - Columns {"Girls","Boys"}, {"Xena","Hercules"}, {"Athena","Hades"}, }   local newTable = tableBuilder.new(tRowData) return newTable -- gives mw.html data for the table... --   local tableOutput = newTable:getTable --   return tableOutput -- Output: the full table-details for html... end

function p.main(frame) local a = getargs(frame) local item, retval

--   item = testTable if not a[1] or a[1] == '' then item = testTable retval = item:getTable return retval elseif a[1] == 'div' then item = testDiv retval = tostring(item) return retval end retval = "I am here" if a[1] == 'purple' then local item2 local caption = "Heros" local styling = "color:purple" local cssclass = { "bluetable", "greentext" } --local ts = { style = styling, } item2 = testTable -- does whole table and caption at top too... --item2:setTableFormat(caption,styling,{}) -- only wanted row-1 all-cols (header) item2:setRowFormat(1,{style="color:purple"}) --item2:setCellStyle(1,1,"color",'purple') --item2:setCellStyle(1,2,"color",'purple') retval = item2:getTable end return retval end

return p