Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Module:Clade/sequential/sandbox

From Wikipedia, the free encyclopedia
local p = {}
local pargs 
local clade = require("Module:Clade").main

local function getMax()
	local i=1
	local max
    while i<50 do
       	if  pargs [i] then 
       		max = i 
       		i=i+1
		else
       	    break
    	end
    end
    return max
end

function p.clade(frame,i,max)  -- |1= is basal at top
	local args = {}
	
	args[1] = pargs [i]
	args['label1'] = pargs ['label'..tostring(i)] 
	args['sublabel1'] = pargs ['sublabel'..tostring(i)] 

	if i+1 == max then 
		args[2] = pargs [i+1]
		args['label2'] = pargs ['label'..tostring(i+1)]	
		args['sublabel2'] = pargs ['sublabel'..tostring(i+1)]	
	else
		args[2] = p.clade(frame,i+1,max)       -- or the result of the next pair
	end
	
    if i == 1 then args.style = frame.args.style or pargs.style or "" end
    if pargs ['reverse'] then args.reverse = 'true' end

	return clade(frame:newChild{title="Module:Clade/sequential", args = args})
end

function p.inverseClade(frame,i,max) -- |1= innermost at bottom
	local args = {}
	
	args[2] = pargs [i]
	args['label2'] = pargs ['label'..tostring(i)] 
	args['sublabel2'] = pargs ['sublabel'..tostring(i)] 
	if i-1 == 1 then 
		args[1] = pargs [i-1]
		args['label1'] = pargs ['label'..tostring(i-1)]	
		args['sublabel1'] = pargs ['sublabel'..tostring(i-1)]	
	else
		args[1] = p.inverseClade(frame,i-1,max)       -- or the result of the next pair
	end

	if i == max then args.style = frame.args.style or pargs.style or "" end
    if pargs ['reverse'] then args.reverse = 'true' end

	return clade(frame:newChild{title="Module:Clade/sequential", args = args})
end

function p.inverseClade2(frame,i,max)  -- |1= is innermost at bottom
	local args = {}
	
	args[1] = pargs [i]
	args['label1'] = pargs ['label'..tostring(i)] 
	if i-1 == 1 then 
		args[2] = pargs [i-1]
		args['label2'] = pargs ['label'..tostring(i-1)]	
	else
		args[2] = p.inverseClade(frame,i-1,max)       -- or the result of the next pair
	end

	if i == max then args.style = frame.args.style or pargs.style or "" end

	return clade(frame:newChild{title="Module:Clade/sequential", args = args})
end

function p._main(frame)
	local contentString
    local max = getMax()

    if pargs['inverse'] then
        contentString  = p.inverseClade(frame,max,max)
    else
    	contentString  = p.clade(frame,1,max)
    end
    
	return contentString 
end

function p.main(frame)

    pargs = frame:getParent().args
	
	return p._main(frame)
end

p[""] = function (frame)

    pargs = frame.args
	
	return p._main(frame:newChild{title="Template:Clade sequential", args={}})
end

return p