imported>Trappist the monk
No edit summary
 
(No difference)

Latest revision as of 16:18, 6 September 2022

Documentation for this module may be created at Module:Sandbox/trappist the monk/template params/data/doc

--[[--------------------------< P A R A M _ N A M E S _ G E T >------------------------------------------------

this does not work.  title_object gets the object for the page that the template is used on, not for the template
calling Module:Check for unknown parameters.  Bother.

read the unparsed content of a template and create a list of all parameters used in that template page.  may be
useful to replace the manually curated lists of parameters given to Module:Check for unknown parameters.

to fetch the data, use:
	local data.known_params_t = mw.loadData ('Module:Sandbox/trappist the monk/template params/data')

]]
local known_params_t = {};														-- associative table to hold each <param name> from any {{{<param name> that we find
local title;

local function param_names_get()

	local template_content;														-- unparsed template content goes here
	local title_object = mw.title.getCurrentTitle();							-- create a title object for the current title

	title = title_object.prefixedText;
	if 10 == title_object.namespace then										-- must be template namespace
		template_content = title_object:getContent();							-- get the template's raw text
	else
		template_content = mw.title.new('Template:EB1911'):getContent() or '';	-- for development
--		return known_params_t;													-- not in template namespace, return an empty table;  TODO: error message instead?
	end

	for param in template_content:gmatch ('{{{([^|}]+)') do
		known_params_t[param] = 1;												-- save it
	end

	return known_params_t;
end


--[[--------------------------< E X P O R T S >----------------------------------------------------------------
]]

return {
	known_params_t = param_names_get(),
	title = title
	}