<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://kcwiki-en.mirairepository.net/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AGetArgs</id>
	<title>Module:GetArgs - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://kcwiki-en.mirairepository.net/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AGetArgs"/>
	<link rel="alternate" type="text/html" href="https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;action=history"/>
	<updated>2026-04-15T06:10:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;diff=86543&amp;oldid=prev</id>
		<title>Botkaze: 4 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;diff=86543&amp;oldid=prev"/>
		<updated>2021-05-12T11:50:37Z</updated>

		<summary type="html">&lt;p&gt;4 revisions imported&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:50, 12 May 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Botkaze</name></author>
	</entry>
	<entry>
		<id>https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;diff=86542&amp;oldid=prev</id>
		<title>がか: Removed protection from &quot;Module:GetArgs&quot;</title>
		<link rel="alternate" type="text/html" href="https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;diff=86542&amp;oldid=prev"/>
		<updated>2018-08-13T14:53:42Z</updated>

		<summary type="html">&lt;p&gt;Removed protection from &amp;quot;&lt;a href=&quot;/Module:GetArgs&quot; title=&quot;Module:GetArgs&quot;&gt;Module:GetArgs&lt;/a&gt;&amp;quot;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:53, 13 August 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>がか</name></author>
	</entry>
	<entry>
		<id>https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;diff=86541&amp;oldid=prev</id>
		<title>com&gt;Ckwng: Update to commit 4b5069155bdc582b5a0d39b96968cfdd0cbe2204 from https://gerrit.wikimedia.org/r/#/c/158323/</title>
		<link rel="alternate" type="text/html" href="https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;diff=86541&amp;oldid=prev"/>
		<updated>2015-07-17T00:36:34Z</updated>

		<summary type="html">&lt;p&gt;Update to commit 4b5069155bdc582b5a0d39b96968cfdd0cbe2204 from https://gerrit.wikimedia.org/r/#/c/158323/&lt;/p&gt;
&lt;a href=&quot;https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;amp;diff=86541&amp;amp;oldid=86540&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>com&gt;Ckwng</name></author>
	</entry>
	<entry>
		<id>https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;diff=86540&amp;oldid=prev</id>
		<title>com&gt;Ckwng: Protected &quot;Module:GetArgs&quot;: High traffic page: This module is used by an extremely high number of pages. It is also based upon the getArgs built-in in Scribunto, so it should not be edited except to update. (‎[edit=autoconfirmed] (indefinite) ‎[mo</title>
		<link rel="alternate" type="text/html" href="https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;diff=86540&amp;oldid=prev"/>
		<updated>2015-07-16T23:45:08Z</updated>

		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/Module:GetArgs&quot; title=&quot;Module:GetArgs&quot;&gt;Module:GetArgs&lt;/a&gt;&amp;quot;: High traffic page: This module is used by an extremely high number of pages. It is also based upon the getArgs built-in in Scribunto, so it should not be edited except to update. (‎[edit=autoconfirmed] (indefinite) ‎[mo&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 23:45, 16 July 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>com&gt;Ckwng</name></author>
	</entry>
	<entry>
		<id>https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;diff=86539&amp;oldid=prev</id>
		<title>com&gt;Ckwng: Testing if Scribunto works, 'cause templates are really stupid =(</title>
		<link rel="alternate" type="text/html" href="https://kcwiki-en.mirairepository.net/w/index.php?title=Module:GetArgs&amp;diff=86539&amp;oldid=prev"/>
		<updated>2014-11-30T00:51:38Z</updated>

		<summary type="html">&lt;p&gt;Testing if Scribunto works, &amp;#039;cause templates are really stupid =(&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
   Handles most of the boilerplate necessary to fetch arguments, such as trimming&lt;br /&gt;
   leading/trailing whitespace, making blank arguments evaluate to false, correctly&lt;br /&gt;
   choosing between current-frame and parent-frame, etc.&lt;br /&gt;
 &lt;br /&gt;
   Originally written on the English Wikipedia by Mr. Stradivarius, Jackmcbarn, and Anomie.&lt;br /&gt;
 &lt;br /&gt;
   Code released under the GPL v2+ as per:&lt;br /&gt;
   https://en.wikipedia.org/w/index.php?diff=624020648&amp;amp;oldid=624019645&lt;br /&gt;
   https://en.wikipedia.org/w/index.php?diff=624073793&amp;amp;oldid=624020648&lt;br /&gt;
 &lt;br /&gt;
   @license GNU GPL v2+&lt;br /&gt;
]]&lt;br /&gt;
 &lt;br /&gt;
local libraryUtil = require( 'libraryUtil' )&lt;br /&gt;
 &lt;br /&gt;
local sandboxSuffixPattern = string.format( '/%s$',&lt;br /&gt;
   mw.message.new( 'scribunto-template-sandbox-subpage-name' ):plain():gsub(&amp;quot;%p&amp;quot;, &amp;quot;%%%0&amp;quot;)&lt;br /&gt;
)&lt;br /&gt;
 &lt;br /&gt;
-- Generate four different tidyVal functions, so that we don't have to check the options every&lt;br /&gt;
-- time we call it.&lt;br /&gt;
 &lt;br /&gt;
local function tidyValDefault( k, v )&lt;br /&gt;
   if type( v ) == 'string' then&lt;br /&gt;
       v = v:match( '^%s*(.-)%s*$' )&lt;br /&gt;
       if v == '' then&lt;br /&gt;
           return nil&lt;br /&gt;
       end&lt;br /&gt;
   end&lt;br /&gt;
   return v&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
local function tidyValTrimOnly( k, v )&lt;br /&gt;
   if type( v ) == 'string' then&lt;br /&gt;
       return v:match( '^%s*(.-)%s*$' )&lt;br /&gt;
   else&lt;br /&gt;
       return v&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
local function tidyValRemoveBlanksOnly( k, v )&lt;br /&gt;
   if type( v ) == 'string' and not v:find( '%S' ) then&lt;br /&gt;
       return nil&lt;br /&gt;
   else&lt;br /&gt;
       return v&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
local function tidyValNoChange( k, v )&lt;br /&gt;
   return v&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
return function( options )&lt;br /&gt;
   libraryUtil.checkType( 'getArgs', 1, options, 'table', true )&lt;br /&gt;
   local frame = options.frame&lt;br /&gt;
   if frame == nil then&lt;br /&gt;
       return {}&lt;br /&gt;
   end&lt;br /&gt;
   libraryUtil.checkTypeForNamedArg( 'getArgs', 'frame', frame, 'table' )&lt;br /&gt;
 &lt;br /&gt;
   --[[&lt;br /&gt;
   -- Get the argument tables. If we were passed a valid frame object, see if we're being&lt;br /&gt;
   -- called via a wrapper. If so, then get pargs, the wrapper's arguments (and if&lt;br /&gt;
   -- wrappersUseFrame is set, the frame's arguments as well). Otherwise, just get fargs,&lt;br /&gt;
   -- the frame's arguments. If we weren't passed a valid frame object, we are being called&lt;br /&gt;
   -- from another Lua module or from the debug console, so assume that we were passed a&lt;br /&gt;
   -- table of args directly, and assign it to a new variable (luaArgs).&lt;br /&gt;
   --]]&lt;br /&gt;
   local fargs, pargs, luaArgs&lt;br /&gt;
   if type( frame.args ) == 'table' and type( frame.getParent ) == 'function' then&lt;br /&gt;
       if options.wrappers then&lt;br /&gt;
           local parent = frame:getParent()&lt;br /&gt;
           local found = false&lt;br /&gt;
           if parent then&lt;br /&gt;
               local title = parent:getTitle():gsub( sandboxSuffixPattern, '' )&lt;br /&gt;
               if options.wrappers == title then&lt;br /&gt;
                   found = true&lt;br /&gt;
               elseif type( options.wrappers ) == 'table' then&lt;br /&gt;
                   -- If either a key or a value matches, it's a match&lt;br /&gt;
                   if options.wrappers[title] ~= nil then&lt;br /&gt;
                       found = true&lt;br /&gt;
                   else&lt;br /&gt;
                       for _,v in ipairs( options.wrappers ) do&lt;br /&gt;
                           if v == title then&lt;br /&gt;
                               found = true&lt;br /&gt;
                               break&lt;br /&gt;
                           end&lt;br /&gt;
                       end&lt;br /&gt;
                   end&lt;br /&gt;
               end&lt;br /&gt;
 &lt;br /&gt;
               if found then&lt;br /&gt;
                   pargs = parent.args&lt;br /&gt;
               end&lt;br /&gt;
           end&lt;br /&gt;
 &lt;br /&gt;
           if not found or options.wrappersUseFrame then&lt;br /&gt;
               fargs = frame.args&lt;br /&gt;
           end&lt;br /&gt;
       else&lt;br /&gt;
           fargs = frame.args&lt;br /&gt;
       end&lt;br /&gt;
   else&lt;br /&gt;
       luaArgs = frame&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
   -- Set the order of precedence of the argument tables. If the variables are nil, nothing&lt;br /&gt;
   -- will be added to the table, which is how we avoid clashes between the frame/parent&lt;br /&gt;
   -- args and the Lua args.&lt;br /&gt;
   local argTables = { pargs }&lt;br /&gt;
   argTables[#argTables + 1] = fargs&lt;br /&gt;
   argTables[#argTables + 1] = luaArgs&lt;br /&gt;
 &lt;br /&gt;
   -- Generate the tidyVal function. If it has been specified by the user, we use that; if&lt;br /&gt;
   -- not, we choose one of four functions depending on the options chosen. This is so that&lt;br /&gt;
   -- we don't have to call the options table every time the function is called.&lt;br /&gt;
   local tidyVal = options.valueFunc&lt;br /&gt;
   if tidyVal then&lt;br /&gt;
       libraryUtil.checkTypeForNamedArg( 'getArgs', 'valueFunc', tidyVal, 'function' )&lt;br /&gt;
   elseif options.trim ~= false then&lt;br /&gt;
       if options.removeBlanks ~= false then&lt;br /&gt;
           tidyVal = tidyValDefault&lt;br /&gt;
       else&lt;br /&gt;
           tidyVal = tidyValTrimOnly&lt;br /&gt;
       end&lt;br /&gt;
   else&lt;br /&gt;
       if options.removeBlanks ~= false then&lt;br /&gt;
           tidyVal = tidyValRemoveBlanksOnly&lt;br /&gt;
       else&lt;br /&gt;
           tidyVal = tidyValNoChange&lt;br /&gt;
       end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
   -- Set up the args, fetchedArgs and nilArgs tables. args will be the one accessed from&lt;br /&gt;
   -- functions, and fetchedArgs will hold the actual arguments. Nil arguments are memoized&lt;br /&gt;
   -- in nilArgs, and args_mt connects all of them together.&lt;br /&gt;
   local args, fetchedArgs, nilArgs, args_mt = {}, {}, {}, {}&lt;br /&gt;
   local donePairs, doneIpairs = false, false&lt;br /&gt;
 &lt;br /&gt;
   local function mergeArgs( iterator, tables )&lt;br /&gt;
       -- Accepts multiple tables as input and merges their keys and values into one&lt;br /&gt;
       -- table using the specified iterator. If a value is already present, it is not&lt;br /&gt;
       -- overwritten; tables listed earlier have precedence. We are also memoizing nil&lt;br /&gt;
       -- values, but those values can be overwritten.&lt;br /&gt;
       for _, t in ipairs( tables ) do&lt;br /&gt;
           for key, val in iterator( t ) do&lt;br /&gt;
               if fetchedArgs[key] == nil then&lt;br /&gt;
                   local tidiedVal = tidyVal( key, val )&lt;br /&gt;
                   if tidiedVal == nil then&lt;br /&gt;
                       nilArgs[key] = true&lt;br /&gt;
                   else&lt;br /&gt;
                       fetchedArgs[key] = tidiedVal&lt;br /&gt;
                   end&lt;br /&gt;
               end&lt;br /&gt;
           end&lt;br /&gt;
       end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
   -- Define metatable behaviour. Arguments are memoized in the fetchedArgs table, and are&lt;br /&gt;
   -- only fetched from the argument tables once. Fetching arguments from the argument&lt;br /&gt;
   -- tables is the most resource-intensive step in this module, so we try and avoid it&lt;br /&gt;
   -- where possible. For this reason, nil arguments are also memoized, in the nilArgs&lt;br /&gt;
   -- table. Also, we keep a record in the metatable of when pairs and ipairs have been&lt;br /&gt;
   -- called, so we do not run pairs and ipairs on the argument tables more than once. We&lt;br /&gt;
   -- also do not run ipairs on fargs and pargs if pairs has already been run, as all the&lt;br /&gt;
   -- arguments will already have been copied over.&lt;br /&gt;
 &lt;br /&gt;
   function args_mt.__index( t, key )&lt;br /&gt;
       -- Fetches an argument when the args table is indexed. First we check to see if&lt;br /&gt;
       -- the value is memoized, and if not we try and fetch it from the argument&lt;br /&gt;
       -- tables. When we check memoization, we need to check fetchedArgs before&lt;br /&gt;
       -- nilArgs, as both can be non-nil at the same time. If the argument is not&lt;br /&gt;
       -- present in fetchedArgs, we also check whether pairs has been run yet. If&lt;br /&gt;
       -- pairs has already been run, we return nil. This is because all the arguments&lt;br /&gt;
       -- will have already been copied into fetchedArgs by the mergeArgs function,&lt;br /&gt;
       -- meaning that any other arguments must be nil.&lt;br /&gt;
       local val = fetchedArgs[key]&lt;br /&gt;
       if val ~= nil then&lt;br /&gt;
           return val&lt;br /&gt;
       elseif donePairs or nilArgs[key] then&lt;br /&gt;
           return nil&lt;br /&gt;
       end&lt;br /&gt;
       for _, argTable in ipairs( argTables ) do&lt;br /&gt;
           local argTableVal = tidyVal( key, argTable[key] )&lt;br /&gt;
           if argTableVal == nil then&lt;br /&gt;
               nilArgs[key] = true&lt;br /&gt;
           else&lt;br /&gt;
               fetchedArgs[key] = argTableVal&lt;br /&gt;
               return argTableVal&lt;br /&gt;
           end&lt;br /&gt;
       end&lt;br /&gt;
       return nil&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
   function args_mt.__newindex( t, key, val )&lt;br /&gt;
       if val == nil then&lt;br /&gt;
           -- If the argument is to be overwritten with nil, we need to memoize the&lt;br /&gt;
           -- nil in nilArgs, so that the value isn't looked up in the argument&lt;br /&gt;
           -- tables if it is accessed again.&lt;br /&gt;
           nilArgs[key] = true&lt;br /&gt;
       end&lt;br /&gt;
       fetchedArgs[key] = val&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
   function args_mt.__pairs()&lt;br /&gt;
       if not donePairs then&lt;br /&gt;
           donePairs = true&lt;br /&gt;
           mergeArgs( pairs, argTables )&lt;br /&gt;
       end&lt;br /&gt;
       return pairs( fetchedArgs )&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
   function args_mt.__ipairs()&lt;br /&gt;
       if not doneIpairs and not donePairs then&lt;br /&gt;
           doneIpairs = true&lt;br /&gt;
           mergeArgs( ipairs, argTables )&lt;br /&gt;
       end&lt;br /&gt;
       return ipairs( fetchedArgs )&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
   return setmetatable( args, args_mt )&lt;br /&gt;
end&lt;/div&gt;</summary>
		<author><name>com&gt;Ckwng</name></author>
	</entry>
</feed>