<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.signal-st.com/index.php?action=history&amp;feed=atom&amp;title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%3ATemplate_invocation</id>
	<title>モジュール:Template invocation - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.signal-st.com/index.php?action=history&amp;feed=atom&amp;title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%3ATemplate_invocation"/>
	<link rel="alternate" type="text/html" href="https://wiki.signal-st.com/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Template_invocation&amp;action=history"/>
	<updated>2026-04-19T02:33:23Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.signal-st.com/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Template_invocation&amp;diff=910&amp;oldid=prev</id>
		<title>羽井出: 1版 をインポートしました: Main, Pathnavなど</title>
		<link rel="alternate" type="text/html" href="https://wiki.signal-st.com/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Template_invocation&amp;diff=910&amp;oldid=prev"/>
		<updated>2025-01-11T13:56:29Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました: Main, Pathnavなど&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;ja&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;2025年1月11日 (土) 22:56時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&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>https://wiki.signal-st.com/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Template_invocation&amp;diff=909&amp;oldid=prev</id>
		<title>ja&gt;本日晴天: :en:Module:Template invocationの2024年9月5日 (木) 20:21 (UTC)の版より更新</title>
		<link rel="alternate" type="text/html" href="https://wiki.signal-st.com/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:Template_invocation&amp;diff=909&amp;oldid=prev"/>
		<updated>2024-12-05T11:10:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;/index.php?title=En:Module:Template_invocation&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;「En:Module:Template invocation」 (存在しないページ)&quot;&gt;en:Module:Template invocation&lt;/a&gt;の&lt;a href=&quot;/index.php?title=En:Special:Permalink/1244228307&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;「En:Special:Permalink/1244228307」 (存在しないページ)&quot;&gt;2024年9月5日 (木) 20:21 (UTC)の版&lt;/a&gt;より更新&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 or #title.prefixedText == 0 or #title.interwiki &amp;gt; 0 then&lt;br /&gt;
			error(&amp;quot;name関数のtitle引数の値が不正です&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;name関数の第1引数は文字列かmw.titleオブジェクトでなければなりません&amp;quot;, 2)&lt;br /&gt;
	end&lt;br /&gt;
	if title.namespace == 10 then&lt;br /&gt;
		local text = title.text&lt;br /&gt;
		local check = mw.title.new(text, 10)&lt;br /&gt;
		-- Exclude the prefix, unless we have something like &amp;quot;Template:Category:Foo&amp;quot;, which can&amp;#039;t be abbreviated to &amp;quot;Category:Foo&amp;quot;.&lt;br /&gt;
		return check and mw.title.equals(title, check) and text or title.prefixedText&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;
--         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;invocationの第2引数の値が不正です（引数名と引数値は文字列か数字しか受け付けません）&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] = 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 which needs to be displayed as a named arg.&lt;br /&gt;
		else&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;
	end&lt;br /&gt;
	local keys = {} -- sort parameter list; better than arbitrary order&lt;br /&gt;
	for k, _ in pairs(invArgs) do&lt;br /&gt;
		keys[#keys + 1] = k&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(keys,&lt;br /&gt;
		function (a, b)&lt;br /&gt;
			-- Sort with keys of type number first, then string.&lt;br /&gt;
			if type(a) == type(b) then&lt;br /&gt;
				return a &amp;lt; b&lt;br /&gt;
			elseif type(a) == &amp;#039;number&amp;#039; then&lt;br /&gt;
				return true&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	)&lt;br /&gt;
	&lt;br /&gt;
	local maybeSpace = &amp;#039;&amp;#039; -- First named parameter should not be separated by a space&lt;br /&gt;
	for _, v in ipairs(keys) do -- Add named args based on sorted parameter list&lt;br /&gt;
		ret[#ret + 1] = maybeSpace .. seps.pipe&lt;br /&gt;
		ret[#ret + 1] = tostring(v)&lt;br /&gt;
		ret[#ret + 1] = seps.equals&lt;br /&gt;
		ret[#ret + 1] = invArgs[v]&lt;br /&gt;
		maybeSpace = &amp;#039; &amp;#039;&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>ja&gt;本日晴天</name></author>
	</entry>
</feed>