The wiki has moved!

Visit the new wiki at stationeers-wiki.com The old wiki here at legacy.stationeers-wiki.com will sunset eventually.

Edits made after the 7th of March 6PM EST were NOT carried over to the new server as previously announced right here in this box.

 Actions

Module

Difference between revisions of "Parameters"

From Unofficial Stationeers Wiki

(Alpha port of User:Alakzi/parameters.py)
 
Line 1: Line 1:
-- This module implements [[]].
+
-- This module implements [[Template:Parameters]].
 
-- [SublimeLinter luacheck-globals:mw]
 
-- [SublimeLinter luacheck-globals:mw]
  

Revision as of 10:01, 5 June 2015


-- This module implements [[Template:Parameters]].
-- [SublimeLinter luacheck-globals:mw]

local p = {}

local function makeInvokeFunction(funcName)
	return function(frame)
		local getArgs = require('Module:Arguments').getArgs
		return p[funcName](getArgs(frame))
	end
end

local function extractParams(args)
	local removeDuplicates = require('Module:TableTools').removeDuplicates

	local parameters = {}
	for parameter in string.gmatch(args.base, '{{{(.-)%f[}|<>]') do
		table.insert(parameters, parameter)
	end
	return removeDuplicates(parameters)
end

function p._demo(args)
	return string.format('{{Parameter names example|%s}}',
		table.concat(extractParams(args), '|'))
end

function p._list(args)
	local list = require('Module:List').bulleted
	return list(extractParams(args))
end

p.demo = makeInvokeFunction('_demo')
p.list = makeInvokeFunction('_list')

return p