<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://ru.ru-skazki.ru/index.php?action=history&amp;feed=atom&amp;title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C%3ATemplate_invocation</id>
	<title>Модуль:Template invocation - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://ru.ru-skazki.ru/index.php?action=history&amp;feed=atom&amp;title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C%3ATemplate_invocation"/>
	<link rel="alternate" type="text/html" href="http://ru.ru-skazki.ru/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:Template_invocation&amp;action=history"/>
	<updated>2026-04-11T10:20:08Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>http://ru.ru-skazki.ru/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:Template_invocation&amp;diff=4323&amp;oldid=prev</id>
		<title>Импортёр: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://ru.ru-skazki.ru/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:Template_invocation&amp;diff=4323&amp;oldid=prev"/>
		<updated>2024-05-01T09:53:39Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 12:53, 1 мая 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Импортёр</name></author>
	</entry>
	<entry>
		<id>http://ru.ru-skazki.ru/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:Template_invocation&amp;diff=4322&amp;oldid=prev</id>
		<title>ru&gt;Andras: Новая страница: «-- This module provides functions for making MediaWiki template invocations.  local checkType = require(&#039;libraryUtil&#039;).checkType  local p = {}  ------------------------------------------------------------------------ --         Name:  p.name --      Purpose:  Find a template invocation name from a page name or a --                mw.title object. --  Description:  This function detects whether a string or a mw.title --                object has been passed i...»</title>
		<link rel="alternate" type="text/html" href="http://ru.ru-skazki.ru/index.php?title=%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D1%8C:Template_invocation&amp;diff=4322&amp;oldid=prev"/>
		<updated>2023-06-04T16:55:49Z</updated>

		<summary type="html">&lt;p&gt;Новая страница: «-- This module provides functions for making MediaWiki template invocations.  local checkType = require(&amp;#039;libraryUtil&amp;#039;).checkType  local p = {}  ------------------------------------------------------------------------ --         Name:  p.name --      Purpose:  Find a template invocation name from a page name or a --                mw.title object. --  Description:  This function detects whether a string or a mw.title --                object has been passed i...»&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module provides functions for making MediaWiki template invocations.&lt;br /&gt;
&lt;br /&gt;
local checkType = require(&amp;#039;libraryUtil&amp;#039;).checkType&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
--         Name:  p.name&lt;br /&gt;
--      Purpose:  Find a template invocation name from a page name or a&lt;br /&gt;
--                mw.title object.&lt;br /&gt;
--  Description:  This function detects whether a string or a mw.title&lt;br /&gt;
--                object has been passed in, and uses that to find a&lt;br /&gt;
--                template name as it is used in template invocations.&lt;br /&gt;
--   Parameters:  title - full page name or mw.title object for the&lt;br /&gt;
--                template (string or mw.title object)&lt;br /&gt;
--      Returns:  String&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function p.name(title)&lt;br /&gt;
	if type(title) == &amp;#039;string&amp;#039; then&lt;br /&gt;
		title = mw.title.new(title)&lt;br /&gt;
		if not title then&lt;br /&gt;
			error(&amp;quot;invalid title in parameter #1 of function &amp;#039;name&amp;#039;&amp;quot;, 2)&lt;br /&gt;
		end&lt;br /&gt;
	elseif type(title) ~= &amp;#039;table&amp;#039; or type(title.getContent) ~= &amp;#039;function&amp;#039; then&lt;br /&gt;
		error(&amp;quot;parameter #1 of function &amp;#039;name&amp;#039; must be a string or a mw.title object&amp;quot;, 2)&lt;br /&gt;
	end&lt;br /&gt;
	if title.namespace == 10 then&lt;br /&gt;
		return title.text&lt;br /&gt;
	elseif title.namespace == 0 then&lt;br /&gt;
		return &amp;#039;:&amp;#039; .. title.prefixedText&lt;br /&gt;
	else&lt;br /&gt;
		return title.prefixedText&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
--         Name:  p.invocation&lt;br /&gt;
--      Purpose:  Construct a MediaWiki template invocation.&lt;br /&gt;
--  Description:  This function makes a template invocation from the&lt;br /&gt;
--                name and the arguments given. Note that it isn&amp;#039;t&lt;br /&gt;
--                perfect: we have no way of knowing what whitespace was&lt;br /&gt;
--                in the original invocation, the named parameters will be&lt;br /&gt;
--                alphabetically sorted, and any parameters with duplicate keys&lt;br /&gt;
--                will be removed.&lt;br /&gt;
--   Parameters:  name - the template name, formatted as it will appear&lt;br /&gt;
--                    in the invocation. (string)&lt;br /&gt;
--                args - a table of template arguments. (table)&lt;br /&gt;
--                format - formatting options. (string, optional)&lt;br /&gt;
--                    Set to &amp;quot;nowiki&amp;quot; to escape, curly braces, pipes and&lt;br /&gt;
--                    equals signs with their HTML entities. The default&lt;br /&gt;
--                    is unescaped.&lt;br /&gt;
--      Returns:  String&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function p.invocation(name, args, format)&lt;br /&gt;
	checkType(&amp;#039;invocation&amp;#039;, 1, name, &amp;#039;string&amp;#039;)&lt;br /&gt;
	checkType(&amp;#039;invocation&amp;#039;, 2, args, &amp;#039;table&amp;#039;)&lt;br /&gt;
	checkType(&amp;#039;invocation&amp;#039;, 3, format, &amp;#039;string&amp;#039;, true)&lt;br /&gt;
&lt;br /&gt;
	-- Validate the args table and make a copy to work from. We need to&lt;br /&gt;
	-- make a copy of the table rather than just using the original, as&lt;br /&gt;
	-- some of the values may be erased when building the invocation.&lt;br /&gt;
	local invArgs = {}&lt;br /&gt;
	for k, v in pairs(args) do&lt;br /&gt;
		local typek = type(k)&lt;br /&gt;
		local typev = type(v)&lt;br /&gt;
		if typek ~= &amp;#039;string&amp;#039; and typek ~= &amp;#039;number&amp;#039;&lt;br /&gt;
			or typev ~= &amp;#039;string&amp;#039; and typev ~= &amp;#039;number&amp;#039;&lt;br /&gt;
		then&lt;br /&gt;
			error(&amp;quot;invalid arguments table in parameter #2 of &amp;quot; ..&lt;br /&gt;
			&amp;quot;&amp;#039;invocation&amp;#039; (keys and values must be strings or numbers)&amp;quot;, 2)&lt;br /&gt;
		end&lt;br /&gt;
		invArgs[k] = v&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Get the separators to use.&lt;br /&gt;
	local seps = {&lt;br /&gt;
		openb = &amp;#039;{{&amp;#039;,&lt;br /&gt;
		closeb = &amp;#039;}}&amp;#039;,&lt;br /&gt;
		pipe = &amp;#039;|&amp;#039;,&lt;br /&gt;
		equals = &amp;#039;=&amp;#039;&lt;br /&gt;
	}&lt;br /&gt;
	if format == &amp;#039;nowiki&amp;#039; then&lt;br /&gt;
		for k, v in pairs(seps) do&lt;br /&gt;
			seps[k] = mw.text.nowiki(v)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Build the invocation body with numbered args first, then named.&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	ret[#ret + 1] = seps.openb&lt;br /&gt;
	ret[#ret + 1] = mw.getContentLanguage():lcfirst(name)&lt;br /&gt;
	for k, v in ipairs(invArgs) do&lt;br /&gt;
		if type(v) == &amp;#039;string&amp;#039; and v:find(&amp;#039;=&amp;#039;, 1, true) then&lt;br /&gt;
			-- Likely something like 1=foo=bar, we need to do it as a named arg&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
		ret[#ret + 1] = seps.pipe&lt;br /&gt;
		ret[#ret + 1] = v&lt;br /&gt;
		invArgs[k] = nil -- Erase the key so that we don&amp;#039;t add the value twice&lt;br /&gt;
	end&lt;br /&gt;
	local invArgs_list = {} -- sort a parameter list; preferable to randomly sorted output&lt;br /&gt;
	for k, v in pairs(invArgs) do&lt;br /&gt;
		invArgs_list[#invArgs_list + 1] = k&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(invArgs_list)&lt;br /&gt;
	for i, v in ipairs(invArgs_list) do -- Add named args based on sorted parameter list&lt;br /&gt;
		ret[#ret + 1] = seps.pipe&lt;br /&gt;
		ret[#ret + 1] = v&lt;br /&gt;
		ret[#ret + 1] = seps.equals&lt;br /&gt;
		ret[#ret + 1] = invArgs[v]&lt;br /&gt;
	end&lt;br /&gt;
	ret[#ret + 1] = seps.closeb&lt;br /&gt;
&lt;br /&gt;
	return table.concat(ret)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>ru&gt;Andras</name></author>
	</entry>
</feed>