「ヘルプ:Templates」を編集中

移動先: 案内検索

警告: ログインしていません。編集を行うと、あなたの IP アドレスが公開されます。ログインまたはアカウントを作成すれば、あなたの編集はその利用者名とともに表示されるほか、その他の利点もあります。

この編集を取り消せます。 下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 編集中の文章
1行目: 1行目:
<languages />
+
<languages/>
 
{{TNT|PD Help Page}}
 
{{TNT|PD Help Page}}
 
<translate>
 
<translate>
50行目: 50行目:
 
<translate>
 
<translate>
 
<!--T:16-->
 
<!--T:16-->
* <code><nowiki>{{subst:Name}}</nowiki></code> — when this template link is used, it will be replaced once and for all with the content of <nowiki>[[Template:Name]]</nowiki> as of the time the page with the link is '''saved''': a copy of the contents of <nowiki>[[Template:Name]]</nowiki> will be ''substituted'' for the template link. The contents are then a part of the including page, and can be edited normally, separately from the original. ''Note'': later changes to the source template page will ''not'' be propagated to the page with the template link.
+
* <code><nowiki>{{subst:Name}}</nowiki></code> — when this template link is used, it will be replaced once and for all with the content of <nowiki>[[Template:Name]]</nowiki> as of the time the page with the link is '''saved''': a copy of the contents of <nowiki>[[Template:Name]]</nowiki> will be ''substituted'' for the template link. The contents are then a part of the including page, and can be edited normally, separately from the original. ''Note'': changes to the source template page will ''not'' be propagated to the page with the template link.
 
</translate>
 
</translate>
 
<translate>
 
<translate>
96行目: 96行目:
  
 
<!--T:30-->
 
<!--T:30-->
The thank you note will have a reason (in this case, "all your effort") and a signature ("Me"). Your objective is that any user be able to thank any other user, for any reason whatsoever.
+
The thank you note will have a reason (in this case, "all your effort") and a signature ("Me"). Your objective is that any user is able to thank any other user, for any reason whatsoever.
  
 
<!--T:31-->
 
<!--T:31-->
 
So that the note will look similar everywhere it is used, you can define a template called [[Template:Thankyou]], for example. Although the note should look similar whenever a user thanks another user, its specific contents (i.e. the reason and the signature) will be different. For that reason, you should pass them as parameters. If we ignore the remaining elements to format the box and place the image, the core content of the template will be this:
 
So that the note will look similar everywhere it is used, you can define a template called [[Template:Thankyou]], for example. Although the note should look similar whenever a user thanks another user, its specific contents (i.e. the reason and the signature) will be different. For that reason, you should pass them as parameters. If we ignore the remaining elements to format the box and place the image, the core content of the template will be this:
</translate>
 
  
<source lang="moin">
+
<!--T:32-->
<translate><!--T:32-->
+
<pre><nowiki>'''A little thank you...'''
'''A little thank you...'''
 
 
for {{{1}}}.
 
for {{{1}}}.
hugs, {{{2}}}</translate>
+
hugs, {{{2}}}</nowiki></pre>
</source>
 
  
<translate>
 
 
<!--T:33-->
 
<!--T:33-->
 
Notice the use of <tvar|1><code><nowiki>{{{1}}}</nowiki></code></> and <tvar|2><code><nowiki>{{{2}}}</nowiki></code></>. This is the way to identify, within templates, the parameters that will be passed in when the template is used. Note that, within the template, each parameter is surrounded by '''three''' braces: <tvar|braces><code><nowiki>{{{ }}}</nowiki></code></>. This is different from normal template name usage.
 
Notice the use of <tvar|1><code><nowiki>{{{1}}}</nowiki></code></> and <tvar|2><code><nowiki>{{{2}}}</nowiki></code></>. This is the way to identify, within templates, the parameters that will be passed in when the template is used. Note that, within the template, each parameter is surrounded by '''three''' braces: <tvar|braces><code><nowiki>{{{ }}}</nowiki></code></>. This is different from normal template name usage.
144行目: 140行目:
 
<!--T:44-->
 
<!--T:44-->
 
'''Note:''' identifying parameters by order (with <code><nowiki>{{{1}}}</nowiki></code>, etc) works ''only'' with anonymous parameters. If your page identifies any parameter by number or name, as shown below, this method will no longer be available to the template which receives them.
 
'''Note:''' identifying parameters by order (with <code><nowiki>{{{1}}}</nowiki></code>, etc) works ''only'' with anonymous parameters. If your page identifies any parameter by number or name, as shown below, this method will no longer be available to the template which receives them.
 
<!--T:120-->
 
'''Note:''' If an equal sign appears inside an anonymous template parameter, it may be interpreted as a named parameter, treating the text before the equal sign as the parameter name and the text after it as the value.</translate>
 
<translate>
 
<!--T:121-->
 
This is a common problem when you need to include an external link, or an HTML element with attributes (see [[<tvar|task>phab:T16235</>|Task 16235]])</translate>
 
<translate>
 
<!--T:122-->
 
The workaround is to use named parameters instead, or even numbered parameters as explained in the following section.
 
  
 
=== Numbered parameters === <!--T:45-->
 
=== Numbered parameters === <!--T:45-->
205行目: 192行目:
 
<!--T:61-->
 
<!--T:61-->
 
Since no parameters were passed in, the template presents the parameters themselves, instead of their respective values. In these cases, it may be useful to define ''default'' values for the parameters, i.e. values that will be used if no value is passed in. For example, if the template contents are changed to:
 
Since no parameters were passed in, the template presents the parameters themselves, instead of their respective values. In these cases, it may be useful to define ''default'' values for the parameters, i.e. values that will be used if no value is passed in. For example, if the template contents are changed to:
</translate>
 
  
<source lang="moin">
+
<!--T:62-->
<translate><!--T:62-->
+
<pre><nowiki>'''A little thank you...'''
'''A little thank you...'''
 
 
for {{{reason|everything}}}.
 
for {{{reason|everything}}}.
hugs, {{{signature|Me}}}</translate>
+
hugs, {{{signature|Me}}}</nowiki></pre>
</source>
 
  
<translate>
 
 
<!--T:63-->
 
<!--T:63-->
 
then <code><nowiki>{{{reason|everything}}}</nowiki></code> defines that if no parameter <code>{{{reason}}}</code> is provided, then the value <code>everything</code> will be used. Similarly, <code><nowiki>{{{signature|Me}}}</nowiki></code>, defaults parameter <code>{{{signature}}}</code> to value <code>Me</code>. Now, transcluding the template again without passing any parameter, results in the following:
 
then <code><nowiki>{{{reason|everything}}}</nowiki></code> defines that if no parameter <code>{{{reason}}}</code> is provided, then the value <code>everything</code> will be used. Similarly, <code><nowiki>{{{signature|Me}}}</nowiki></code>, defaults parameter <code>{{{signature}}}</code> to value <code>Me</code>. Now, transcluding the template again without passing any parameter, results in the following:
220行目: 203行目:
 
<!-- strictly speaking, this example is false, because the template call was changed to obtain the desired effect - but the effect is the same if the template is defined as described -->
 
<!-- strictly speaking, this example is false, because the template call was changed to obtain the desired effect - but the effect is the same if the template is defined as described -->
 
<translate>
 
<translate>
<!--T:146-->
+
<!--T:64-->
 
{{Thankyou|reason=everything|signature=Me}}
 
{{Thankyou|reason=everything|signature=Me}}
 
=== Order of evaluation === <!--T:64-->
 
Template parameters are fully evaluated before they are passed to the template.
 
So if one of your parameters is a call to another template, what is
 
actually passed is the expanded parameter.
 
 
<!--T:138-->
 
<pre><nowiki>{{Thankyou|reason=visiting ({{Welcome}})|signature=Me}}</nowiki></pre>
 
becomes
 
<pre><nowiki>{{Thankyou|reason=visiting (Hi there! Welcome to this wonderful wiki.)|signature=Me}}</nowiki></pre>
 
before it becomes:
 
 
<!--T:139-->
 
{{Thankyou|reason=visiting (Hi there! Welcome to this wonderful wiki.)|signature=Me}}
 
<!-- Can't use the actual {{Welcome}} as it's defined differently than the example definition given at the start of this page. -->
 
 
<!--T:140-->
 
In a few circumstances, this order of evaluation makes a difference
 
from the alternative.  (The alternative being to check the results
 
of the template call to see if there are additional templates to be
 
expanded.)
 
 
<!--T:141-->
 
First, the name of the template can be expanded at the same time and
 
in the same way as the parameters.
 
 
<!--T:142-->
 
Thus
 
<pre><nowiki>{{Thankyou in {{preferred language}}|signature=Me}}</nowiki></pre>
 
might expand to
 
<pre><nowiki>{{Thankyou in french|signature=Me}}</nowiki></pre>
 
So that a template called <code>Thankyou in french</code> could display the thank you in the preferred language (however that was determined.)
 
 
<!--T:143-->
 
Secondly, the template being called can't construct a template from pieces
 
to be called later.
 
A template that took the form
 
<code><nowiki>{{start of call}}{{end of call}}</nowiki></code>
 
would not work
 
if
 
<code>start of call</code> was <code><nowiki>{{Thankyou|</nowiki></code>
 
and
 
<code>end of call</code> was <code><nowiki>signature=Me}}</nowiki></code>.
 
 
<!--T:144-->
 
Thirdly, the parameter being passed is expanded only once, rather than
 
every place the parameter is used in the template.  This is more
 
efficient on the mediawiki server.
 
 
<!--T:145-->
 
Finally, the template being called can't stop the parameter from being
 
expanded altogether.  Even if a template only uses a parameter in some
 
circumstances, it will always have been expanded before the call was made.
 
  
 
== Control template inclusion == <!--T:65-->
 
== Control template inclusion == <!--T:65-->
306行目: 236行目:
  
 
<!--T:74-->
 
<!--T:74-->
Everything outside <tvar|noinclude><code><nowiki><noinclude></nowiki></code></> and <tvar|includeonly><code><nowiki><includeonly></nowiki></code></> is processed and displayed normally; that is, both when the template page is being viewed directly and when the template is included in another page.</translate>
+
Everything outside <tvar|noinclude><code><nowiki><noinclude></nowiki></code></> and <tvar|includeonly><code><nowiki><includeonly></nowiki></code></> tags is processed and displayed normally; that is, both when the template page is being viewed directly and when the template is included in another page.
<translate>
 
<!--T:127-->
 
The focus is on what is inside these two tags.
 
 
 
<!--T:128-->
 
Everything outside <tvar|onlyinclude><code><nowiki><onlyinclude></nowiki></code></> tags is discarded in the transclusion.</translate>
 
<translate>
 
<!--T:129-->
 
Even sections tagged includeonly are discarded in the transclusion unless they are also tagged as onlyinclude.</translate>
 
<translate>
 
<!--T:130-->
 
The focus is on what is outside this tag.
 
 
 
<!--T:131-->
 
The three partial transclusion tags enable all possible combinations of what is processed and rendered.</translate>
 
<translate>
 
<!--T:132-->
 
Comments also fill a role.
 
  
 
== Organizing templates == <!--T:75-->
 
== Organizing templates == <!--T:75-->
333行目: 245行目:
 
<!--T:77-->
 
<!--T:77-->
 
To find them, users can:
 
To find them, users can:
# Click '''<tvar|special>{{int|specialpages}}</>''' > '''<tvar|all>{{int|allpages}}</>'''
+
# Click '''{{int:specialpages}}''' > '''{{int:allpages}}'''
# In the '''<tvar|ns>{{int|namespace}}</>''' list, choose '''Template''' and click '''<tvar|submit>{{int|allpagessubmit}}</>'''.
+
# In the '''{{int:namespace}}''' list, choose '''Template''' and click '''{{int:allpagessubmit}}'''.
  
 
<!--T:78-->
 
<!--T:78-->
349行目: 261行目:
 
<!--T:80-->
 
<!--T:80-->
 
Then, an editor can simply copy and paste the example to use the template.
 
Then, an editor can simply copy and paste the example to use the template.
 
== Linking to a template == <!--T:133-->
 
 
<!--T:134-->
 
To link to a template instead of including it, use the {{tl|tl}} template.</translate>
 
<translate>
 
<!--T:135-->
 
The name of the template the editor wants to link to goes after the vertical pipe.</translate>
 
<translate>
 
<!--T:136-->
 
For example:</translate>
 
<translate>
 
<!--T:137-->
 
<tvar|code><code><nowiki>{{tl|navbar}}</nowiki></code></> links to the <tvar|navbar>{{tl|navbar}}</> template.
 
  
 
== Copying from one wiki to another == <!--T:81-->
 
== Copying from one wiki to another == <!--T:81-->
376行目: 274行目:
 
<translate>
 
<translate>
 
<!--T:85-->
 
<!--T:85-->
# Go to <tvar|export>[[Special:Export]]</> on the original wiki, and download an .xml file with the complete history of all necessary templates, as follows:
+
# Go to [[Special:Export]] on the original wiki, and download an .xml file with the complete history of all necessary templates, as follows:
 
</translate>
 
</translate>
 
<translate>
 
<translate>
384行目: 282行目:
 
<translate>
 
<translate>
 
<!--T:87-->
 
<!--T:87-->
#* Check the box "<tvar|export>{{int|export-templates}}</>".
+
#* Check the box "{{int:export-templates}}".
 
</translate>
 
</translate>
 
<translate>
 
<translate>
 
<!--T:88-->
 
<!--T:88-->
#* '''Uncheck''' the box "<tvar|export2>{{int|exportcuronly}}</>".
+
#* '''Uncheck''' the box "{{int:exportcuronly}}".
 
</translate>
 
</translate>
 
<translate>
 
<translate>
 
<!--T:89-->
 
<!--T:89-->
#* Click "<tvar|submit>{{int|export-submit}}</>".
+
#* Click "{{int:export-submit}}".
 
</translate>
 
</translate>
 
<translate>
 
<translate>
413行目: 311行目:
  
 
<!--T:118-->
 
<!--T:118-->
After successfully importing the template and all its linked templates from the other wiki, edit it to change customisations to suit your wiki. For example to change a logo, remove redundant categories or red links.
+
After sucessfully importing the template and all its linked templates from the other wiki, edit it to change customisations to suit your wiki. For example to change a logo, remove redundant categories or red links.
  
 
=== Extensions === <!--T:100-->
 
=== Extensions === <!--T:100-->
433行目: 331行目:
 
<!--T:106-->
 
<!--T:106-->
 
# If the copied template is still not working as expected, check if there is code in "MediaWiki:Common.js" or "MediaWiki:Monobook.js" on the original wiki. If so, you can try copying it to "MediaWiki:Common.js" on the new wiki. Normally, it is a good idea to only copy code from trusted sources, and first browsing the code to identify and select the parts that are relevant. You may find comments that can serve as clues to identify the functionality of each part.
 
# If the copied template is still not working as expected, check if there is code in "MediaWiki:Common.js" or "MediaWiki:Monobook.js" on the original wiki. If so, you can try copying it to "MediaWiki:Common.js" on the new wiki. Normally, it is a good idea to only copy code from trusted sources, and first browsing the code to identify and select the parts that are relevant. You may find comments that can serve as clues to identify the functionality of each part.
 
==Note== <!--T:123-->
 
 
<!--T:124-->
 
An experiment shows that if you include a template in itself, it won't put MediaWiki into an infinite recursion.</translate>
 
<translate>
 
<!--T:125-->
 
MediaWiki will find out, and stop with the template's name in bold.</translate>
 
<translate>
 
<!--T:126-->
 
For example, if the content of "Template:Aaaa" is "<tvar|code><code><nowiki>{{Aaaa}}</nowiki></code></>", it'll show as "<tvar|result>'''Template:Aaaa'''</>".
 
  
 
== See also == <!--T:107-->
 
== See also == <!--T:107-->
</translate>
 
  
* {{ll|Help:TemplateData}}
 
<translate>
 
 
<!--T:108-->
 
<!--T:108-->
* <tvar|external>{{ll|Help:External searches}}</> – a template special use case example
+
* [[Special:MyLanguage/Help:External searches|external searches]] – a template special use case example
 
</translate>
 
</translate>
 
<translate>
 
<translate>
 
<!--T:109-->
 
<!--T:109-->
* <tvar|magic>{{ll|Help:Magic words}}</> – fancy stuff you may find in some templates
+
* [[Special:MyLanguage/Help:Magic words|magic words]] – fancy stuff you may find in some templates
 +
</translate>
 +
<translate>
 +
<!--T:110-->
 +
* [[Special:MyLanguage/Help:Parser functions in templates|parser functions in templates]]
 
</translate>
 
</translate>
* {{ll|Help:Parser functions in templates}}
 
 
<translate>
 
<translate>
 
<!--T:111-->
 
<!--T:111-->
* [[<tvar|meta>m:Special:MyLanguage/Help:Template</>|m:Help:Template]] – contains a much more thorough manual on how exactly templates function
+
* {{meta|Help:Template}} – contains a much more thorough manual on how exactly templates function
 
</translate>
 
</translate>
 
<translate>
 
<translate>
 
<!--T:112-->
 
<!--T:112-->
** [[<tvar|meta>m:Special:MyLanguage/Help:Advanced templates</>|m:Help:Advanced templates]] – describes even more advanced techniques such as dynamic template calls and variable variables
+
** {{meta|Help:Advanced templates}} – describes even more advanced techniques such as dynamic template calls and variable variables
 
</translate>
 
</translate>
 
<translate>
 
<translate>
 
<!--T:113-->
 
<!--T:113-->
* [[<tvar|meta>m:Help:Embed page</>|m:Help:Embed page]] – embedding pages from [[<tvar|ns>Special:MyLanguage/Help:Namespaces</>|namespaces]] other than <code>Template:</code>.
+
* {{meta|Help:Embed page}} – embedding pages from [[Special:MyLanguage/Help:Namespaces|namespaces]] other than <code>Template:</code>.
 +
</translate>
 +
<translate>
 +
<!--T:119-->
 +
* [[Manual:Importing Wikipedia infoboxes tutorial|Importing Wikipedia infoboxes tutorial]]
 
</translate>
 
</translate>
* {{ll|Manual:Importing Wikipedia infoboxes tutorial}}
 
  
 
[[Category:Help{{translation}}|Templates]]
 
[[Category:Help{{translation}}|Templates]]
 
[[Category:Template{{translation}}]]
 
[[Category:Template{{translation}}]]
 
[[Category:MediaWiki for site admins{{translation}}]]
 
[[Category:MediaWiki for site admins{{translation}}]]

ひつじ小屋別館2代目への投稿はすべて、他の投稿者によって編集、変更、除去される場合があります。 自分が書いたものが他の人に容赦なく編集されるのを望まない場合は、ここに投稿しないでください。
また、投稿するのは、自分で書いたものか、パブリック ドメインまたはそれに類するフリーな資料からの複製であることを約束してください(詳細はひつじ小屋別館2代目:著作権を参照)。 著作権保護されている作品は、許諾なしに投稿しないでください!

このページを編集するには、下記の確認用の質問に回答してください (詳細):

取り消し | 編集の仕方 (新しいウィンドウで開きます)