<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2Ftrappist_the_monk%2Ftemplate_params</id>
	<title>Module:Sandbox/trappist the monk/template params - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2Ftrappist_the_monk%2Ftemplate_params"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/trappist_the_monk/template_params&amp;action=history"/>
	<updated>2026-08-11T11:17:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/trappist_the_monk/template_params&amp;diff=146635&amp;oldid=prev</id>
		<title>imported&gt;Legoktm: Replace Module:No globals with require( &quot;strict&quot; )</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/trappist_the_monk/template_params&amp;diff=146635&amp;oldid=prev"/>
		<updated>2022-10-23T21:03:52Z</updated>

		<summary type="html">&lt;p&gt;Replace &lt;a href=&quot;/research/Module:No_globals&quot; title=&quot;Module:No globals&quot;&gt;Module:No globals&lt;/a&gt; with require( &amp;quot;strict&amp;quot; )&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;strict&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; P A R A M _ N A M E S _ G E T &amp;gt;------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
read the unparsed content of a template and create a list of all parameters used in that template page.  may be&lt;br /&gt;
useful to replace the manually curated lists of parameters given to Module:Check for unknown parameters.&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Sandbox/trappist the monk/template params|param_names_get}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function param_names_get()&lt;br /&gt;
	local template_content;														-- unparsed template content goes here&lt;br /&gt;
	local title_object = mw.title.getCurrentTitle();							-- create a title object for the current title&lt;br /&gt;
	if 10 == title_object.namespace then										-- must be template namespace&lt;br /&gt;
		template_content = title_object:getContent();							-- get the template&amp;#039;s raw text&lt;br /&gt;
	else&lt;br /&gt;
		template_content = mw.title.new(&amp;#039;Template:EB1911&amp;#039;):getContent() or &amp;#039;&amp;#039;;	-- for development&lt;br /&gt;
--		return &amp;#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;error: Template namespace only&amp;lt;/span&amp;gt;&amp;#039;;		-- not in template namespace, emit an error message and abandon&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local params_t = {};														-- sequence table to hold each &amp;lt;param name&amp;gt; from any {{{&amp;lt;param name&amp;gt; that we find&lt;br /&gt;
	for param in template_content:gmatch (&amp;#039;{{{([^|}]+)&amp;#039;) do&lt;br /&gt;
		table.insert (params_t, param);											-- save it; there may be duplicates which will be cleaned up later&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local out_t = {};															-- sequence table to hold param names for output&lt;br /&gt;
	local log_t = {};															-- a log table for evaluation&lt;br /&gt;
	&lt;br /&gt;
	for _, param in ipairs (params_t) do										-- for each of the parameter names accumulated in &amp;lt;params_t&amp;gt;&lt;br /&gt;
		if not log_t[param] then												-- have we already seen this parameter name?&lt;br /&gt;
			table.insert (out_t, param);										-- no, add &amp;lt;param&amp;gt; to the output sequence table&lt;br /&gt;
			log_t[param] = 1;													-- and add with count of one to the log table&lt;br /&gt;
		else																	-- here for parameter names we&amp;#039;ve seen&lt;br /&gt;
			log_t[param] = log_t[param] + 1;									-- bump the count&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
--	mw.logObject (log_t);														-- emit a log of parameter names and how many times they are used in the template&lt;br /&gt;
	table.sort (out_t);															-- sort list of parameter names&lt;br /&gt;
	return table.concat (out_t, &amp;#039; | &amp;#039;);											-- and make all pretty-like for placement in {{#invoke:Check for unknown parameters|check|...}}&lt;br /&gt;
--	return mw.dumpObject (out_t);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; T E S T &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
a variant of the above that uses Module:Sandbox/trappist the monk/template params/data to fetch the known-&lt;br /&gt;
parameters list&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Sandbox/trappist the monk/template params|test}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function test()&lt;br /&gt;
	local data = mw.loadData (&amp;#039;Module:Sandbox/trappist the monk/template params/data&amp;#039;);	-- load an associative table of known parameter names&lt;br /&gt;
	return mw.dumpObject (known_params_t);&lt;br /&gt;
--	return data.known_params_t[&amp;#039;footnote&amp;#039;]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X P O R T E D   F U N C T I O N S &amp;gt;------------------------------------------&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
--	param_names_get = param_names_get,&lt;br /&gt;
	test = test&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>imported&gt;Legoktm</name></author>
	</entry>
</feed>