<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mindpowe.red/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AUser</id>
	<title>Module:User - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mindpowe.red/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AUser"/>
	<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:User&amp;action=history"/>
	<updated>2026-04-06T18:59:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://mindpowe.red/wiki/index.php?title=Module:User&amp;diff=2872&amp;oldid=prev</id>
		<title>imported&gt;Mr. Stradivarius: comment the validateArg function</title>
		<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:User&amp;diff=2872&amp;oldid=prev"/>
		<updated>2014-04-06T15:43:28Z</updated>

		<summary type="html">&lt;p&gt;comment the validateArg function&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[=[&lt;br /&gt;
-- This module implements {{user}}. {{user}} is a high-use template, sometimes&lt;br /&gt;
-- with thousands of transclusions on a page. This module optimises the&lt;br /&gt;
-- template's performance by reducing the number of parameters called from&lt;br /&gt;
-- wikitext, while still allowing all the features provided by&lt;br /&gt;
-- [[Module:UserLinks]]. It is about twice as fast as the version of {{user}}&lt;br /&gt;
-- that called the {{user-multi}} template from wikitext.&lt;br /&gt;
--]=]&lt;br /&gt;
&lt;br /&gt;
local mUserLinks = require('Module:UserLinks')&lt;br /&gt;
local mShared = require('Module:UserLinks/shared')&lt;br /&gt;
local yesno = require('Module:Yesno')&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function validateArg(arg)&lt;br /&gt;
	-- Validates one argument. Whitespace is stripped, and blank arguments&lt;br /&gt;
	-- are treated as nil.&lt;br /&gt;
	if not arg then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	arg = arg:match('^%s*(.-)%s*$')&lt;br /&gt;
	if arg ~= '' then&lt;br /&gt;
		return arg&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	-- Grab the user, project and lang args from wikitext.&lt;br /&gt;
	local argKeys = {&lt;br /&gt;
		user = {&lt;br /&gt;
			1,&lt;br /&gt;
			'User',&lt;br /&gt;
			'user'&lt;br /&gt;
		},&lt;br /&gt;
		project = {&lt;br /&gt;
			2,&lt;br /&gt;
			'Project',&lt;br /&gt;
			'project'&lt;br /&gt;
		},&lt;br /&gt;
		lang = {&lt;br /&gt;
			3,&lt;br /&gt;
			'Lang',&lt;br /&gt;
			'lang'&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	local origArgs = frame:getParent().args&lt;br /&gt;
	local args = {}&lt;br /&gt;
	for argKey, t in pairs(argKeys) do&lt;br /&gt;
		for i, origArgKey in ipairs(t) do&lt;br /&gt;
			local value = origArgs[origArgKey]&lt;br /&gt;
			value = validateArg(value)&lt;br /&gt;
			if value then&lt;br /&gt;
				args[argKey] = value&lt;br /&gt;
				-- If we have found a value, break the loop. For the average&lt;br /&gt;
				-- invocation this saves two argument lookups.&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Generate options. Some of these need wikitext args also.&lt;br /&gt;
	local options = {&lt;br /&gt;
		span = false,&lt;br /&gt;
		separator = validateArg(origArgs.separator) or 'dot',&lt;br /&gt;
		isDemo = yesno(validateArg(origArgs.demo))&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	-- Input the codes directly. This saves two argument lookups for each&lt;br /&gt;
	-- invocation.&lt;br /&gt;
	local codes = {'t', 'c'}&lt;br /&gt;
	&lt;br /&gt;
	-- Plug the data into [[Module:UserLinks]].&lt;br /&gt;
	local snippets = mUserLinks.getSnippets(args)&lt;br /&gt;
	local links = mUserLinks.getLinks(snippets)&lt;br /&gt;
	local success, result = pcall(mUserLinks.export, codes, links, options)&lt;br /&gt;
	if success then&lt;br /&gt;
		return result&lt;br /&gt;
	else&lt;br /&gt;
		return mShared.makeWikitextError(result, options.isDemo)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Mr. Stradivarius</name></author>
		
	</entry>
</feed>