Module:Sandbox/ChaoticShadow/SongDataLine: Difference between revisions

From TestWiki
Content added Content deleted
No edit summary
No edit summary
Line 6: Line 6:
local root = mw.html.create('ul')
local root = mw.html.create('ul')
local what = ''
local what = ''

function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end


function p.main(frame)
function p.main(frame)
Line 12: Line 25:
for k,v in pairs(args) do
for k,v in pairs(args) do
what = what .. v
what = what .. v
local lines = v:split("\n")
for _,line in ipairs(lines) do
root:tag('li'):wikitext(line)
end
end
end

Revision as of 05:56, 25 June 2021

Documentation for this module may be created at Module:Sandbox/ChaoticShadow/SongDataLine/doc

local getArgs = require('Module:Arguments').getArgs

local p = {}
local args = {}

local root = mw.html.create('ul')
local what = ''

function string:split(delimiter)
  local result = { }
  local from  = 1
  local delim_from, delim_to = string.find( self, delimiter, from  )
  while delim_from do
    table.insert( result, string.sub( self, from , delim_from-1 ) )
    from  = delim_to + 1
    delim_from, delim_to = string.find( self, delimiter, from  )
  end
  table.insert( result, string.sub( self, from  ) )
  return result
end

function p.main(frame)
	args = getArgs(frame)

	for k,v in pairs(args) do
		what = what .. v
		local lines = v:split("\n")
		for _,line in ipairs(lines) do
			root:tag('li'):wikitext(line)
		end
	end
	
	return '<pre>' .. mw.dumpObject(args) .. '</pre>' 
	.. '<br>' .. 
	'<pre>' .. what .. '</pre>'
end

return p