Transclusion/ja

参照読み込み (transclusion: トランスクルージョン) は、一般には特定の文書の内容を別の文書にリンクし参照させることです. ウィキの場合はのテンプレートの機能を用いて、同一の文書を複数の文書に読み込むことができ、読み込み先の文書をいちいち書き換える必要はありません. テンプレートのメッセージは多くの場合、テンプレートの参照読み込みにより表示され、実行にはテンプレートタグを以下のように使用します.



参照読み込みの仕組み


参照元ページを読み込み先ページにトランスクルード (参照読み込み) するには (ウィキペディアなど同一の MediaWiki プロジェクト内の場合) 以下のコードを記述します:

翻訳文 A が処理されるたび、翻訳原文 B (ここではSOMEPAGEに相当) で参照読み込みタグを置いた箇所の全文が処理されます.

For example, you might decide to place a welcome message on every newcomer's talk page. Transclusion creates a "live" link between the template-page and the target-page(s) upon which the message should appear. When the template is edited, all the target-pages are edited too.

You might also decide to create a (template) page with your mailing address and include that template on not only your page, but all your friends' pages as well. When you move your television and couch to another apartment, you can change your address template, and that new information will automatically update on all your friends' pages.

Transclusion Markup & Syntax
参照元が「Template:Welcome」のようにテンプレート名前空間にあるなら、リンク先を書きます.

参照元がメインの記事名前空間 (例: 「VisualEditor) にある場合は、その先頭に半角コロン を付けます.

その他 (例: 「User:Example」) 名前空間にある場合は、参照元の名前空間から始まる長いリンクを書きます.

ソースがターゲット ページの下位ページである場合 (例: "Transclusion/ja") は名前空間に無関係に、下位ページの名前のみを提示します.

語源
Ted Nelson coined the term "transclusion", as well as "hypertext" and "hypermedia", in his 1982 book Literary Machines.



部分的な参照読み込み
By using "noinclude", "onlyinclude" and "includeonly" markup, it is possible to transclude part of a page rather than all of it. Such partial transclusions can also be achieved by transcluding from other pages such as subpages. It is often desirable not to transclude some information, such as template documentation and categories.

Examples of when to use full versus partial transclusion
Use full transclusion when you want to include the full content of a source page in a target page. For example, you could include the full content of a page about apples in a page about tree fruits. Use partial transclusion when you only want to include part of a source page in a target page. For example, you could include only information about Granny Smith apples from a page about apples in a page about ingredients commonly used in baking.



部分的参照読み込みのマークアップ

 * noinclude - The markup  means that the text between the tags is visible exclusively on the source page and cannot be transcluded onto another page. This is useful for template documentation and categories.
 * includeonly - The markup  means that the text between the tags will be hidden on the source page and visible only when transcluded onto a different page. This can be useful, for example, for adding categories to pages transcluding a template, without adding the template itself to these categories.
 * onlyinclude - The markup  means that the text between the tags will be visible on the source page and visible when transcluded onto a different page. This is the most subtle of the partial transclusion tags because it often overrules the others. If there is at least one pair of "onlyinclude" tags on a page, then whenever this page is transcluded, it is only the material within the "onlyinclude" tags that is transcluded. There can be several such "onlyinclude" sections on a page. This can be useful, for example, to repeat a small part of one page on a second one: just surround the small part by onlyinclude tags, and transclude it onto the second page.

You can nest all three transclusion types within each other, which enables you to refine exactly what content is displayed on the current page and is visible on transcluded pages.

下位ページ
You can cut and paste the text to be transcluded into a subpage, then use the name of the subpage in the transclusion template. This approach can be used only where subpages are enabled; for example, on the English Wikipedia, subpages can be used only from User, Talk or Wikipedia pages; currently, subpages cannot be created from main article pages.

Example: you want to discuss the deletion and redirecting of Pussycat to Cat. First, create the subpage Talk:Pussycat/Let's delete Pussycat!, write your comment into it, then transclude it in Talk:Pussycat and Talk:Cat using the template  . Comments posted in either talk page will be shown in both.



特別ページ

 * w:Wikipedia:Transclusion および も参照

Some pages on Special:Specialpages can be transcluded, such as Special:AllPages, Special:PrefixIndex, Special:NewFiles, Special:NewPages, Special:RecentChanges and Special:RecentChangesLinked.

Sample: gives 3 new pages.

URL parameters can be given like template parameters, e. g..



テンプレートの参照読み込みの代替
Occasionally you may want to use a template, but for one reason or another may not want to use transclusion. The automatic one-time copying of a template's code/text to the location of a template tag is called Template substitution or subclusion (substitution + transclusion). To subclude a template's code/text, the template tag is modified from the standard transclusion tag to a substitution tag, simply by adding subst:, creating a tag with the form:.



ラベル付き節の参照読み込み
An extension called Labeled Section Transclusion enables marked sections of text to be transcluded. An extension with a somewhat similar function is extension (unmaintained).

Scribunto
You can transclude page content, or even parts of it, using Lua with the extension. See Module:Transcluder for an example on this wiki.



意味論 MediaWiki
The Semantic MediaWiki extension uses inline queries to query and display semantic data. There are currently two ways to perform transclusion or something similar:


 * 1) Transclusion proper. The display format "embedded" ensures that selected pages (mainspace articles, templates, etc.) are transcluded. As with templates, sections placed between noinclude tags will be omitted.
 * 2) Selected passages in a page can be assigned a property of type 'Text'. These selections can be requested by running an inline query for this type of property.

See inline queries for further information.



MediaWiki での参照読み込みに関連するページ

 * w:Wikipedia:MediaWiki namespace
 * m:Help:MediaWiki namespace
 * m:Help:Variable
 * w:Wikipedia talk:Template namespace

テンプレート

 * w:Wikipedia:Template namespace
 * w:Wikipedia:Template limits



関連項目

 * Request for template transclusion from Commons - コモンズからテンプレートの参照読み込みを要望 (インターウィキ テンプレート他)
 * w:Wikipedia:Substitution (この機能の逆作用)
 * Extension:Labeled Section Transclusion - ラベル付き節の参照読み込み