끼워넣기

From mediawiki.org
This page is a translated version of the page Transclusion and the translation is 42% complete.

끼워넣기(Transclusion)란 일반적으로 참고를 위해 다른 문서를 포함하는 것을 뜻합니다. 위키에서는 같은 내용을 복사 붙여넣기 없이 여러 문서에 을 끼워넣기 위한 것이라는 맥락으로 사용됩니다.

끼워넣기는 어떻게 작동하는가

To transclude any source page (within a single MediaWiki project, such as Wikipedia) within another target page, include the following code: {{SOMEPAGE}}

Whenever the target page A is rendered, the entire content of the source page B (in this case, SOMEPAGE), will be rendered at the location where the transclusion tag was placed.

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

If the source is in the Template namespace (e.g. "Template:Welcome"), just use the name itself, alone: {{Welcome}}

If the source is in the Main article namespace (e.g. "VisualEditor"), a colon (:) must be added in front of the name: {{:VisualEditor}}

If the source is in any other namespace (e.g. "User:Example"), you must use the full name, including the namespace: {{User:Example}}

If the source is a subpage of the target page, (e.g. "Transclusion/ja"), you can simply specify the name of the subpage regardless of namespace: {{/ja}}

Etymology

Ted Nelson coined the term "끼워넣기 ", as well as "hypertext" and "hypermedia", in his 1982 book Literary Machines.

문서 끼워넣기

noinclude, onlyinclude, includeonly를 사용해서 원하는 부분만 끼워넣는 것이 가능합니다. 부분 끼워넣기는 하위문서 등 다른 페이지로부터 끼워서 사용할 수도 있습니다. 경우에 따라서 설명문서나 분류가 포함되지 않아야 할 때도 있기 때문입니다.

전체 끼워넣기와 부분 끼워넣기의 차이

전체 끼워넣기는 만약 모든 내용을 끼워넣고자 할 때 사용합니다. 예를 들어, '사과나무'에 '사과'에 관한 내용 전부를 끼워넣고자 하실 수도 있습니다. 이 경우 부분 끼워넣기를 통해 끼워넣어질 문서에 문서의 코드 부분만 포함하도록 사용할 수 있습니다. 예를 들어 '사과 파이' 문서에서 재료를 설명하기 위해 '사과'에 대한 문서로부터 '파란 사과'를 설명하는 내용만 '사과 파이' 문서에 끼워넣어 봅시다.

부분 끼워넣기 태그

  • noinclude - 오로지 원본 문서에서만 보이고 다른 문서에 끼워넣어질 때 ‎<noinclude>...‎</noinclude>안에 있는 내용은 들어가지 않습니다. 틀에 대한 설명문서와 카테고리를 삽입할 때 유용합니다.
  • includeonly - 원본 문서에는 보이지 않게 해야할 때, ‎<includeonly>...‎</includeonly>안에 있는 내용은 끼워넣어진 문서에서만 보이는 내용입니다. 예를 들어 틀에 의해 삽입되는 분류를 해당 틀에는 삽입하지 않고 문서에만 삽입할 때 유용합니다.
  • onlyinclude - 내용이 ‎<onlyinclude>...‎</onlyinclude>안에 있다면 원본 문서에서도 보이고 원본 문서를 끼워넣은 다른 문서에서도 보일 것입니다. 부분 끼워넣기 태그라고 하기엔 종종 나머지 기능을 포함하므로 이해하기 조금 어려운 태그입니다. 만약 최소한 한 쌍의 "onlyinclude" 태그가 있을 경우 "onlyinclude" 태그에 있는 내용만 끼워넣어집니다. 문서에 이러한 "onlyinclude" 태그가 있을 수 있습니다. 문서와 그 문서를 끼워넣은 문서 모두에 내용을 표시하는데 유용합니다. 작은 부분만 onlyinclude로 김싸서 끼워넣으려는 페이지에 끼워넣어보세요.
‎<nowiki> 태그 안에서 ‎<noinclude>, ‎<includeonly>, ‎<onlyinclude>가 모두 다르게 작동합니다. nowiki 태그는 특수한 태그들을 문자 그대로 표시하는 걸 가능하게 해주며 이는 ‎<noinclude>‎<includeonly>을 설명하기 위함입니다. 하지만, ‎<nowiki>안에 있는 ‎<onlyinclude> 태그는 ‎<onlyinclude> 태그 안에 있는 내용만 생성합니다.
태그 끼워넣어졌을 때 들어가는 실제 내용
<nowiki><noinclude> My content </noinclude></nowiki> <noinclude> My content </noinclude>
<nowiki><includeonly> My content </includeonly></nowiki> <includeonly> My content </includeonly>
<nowiki><onlyinclude>My content</onlyinclude></nowiki> My content

세 가지 끼워넣기 태그 모두 서로 함께 사용할 수 있으며, 이는 보고 있는 페이지에서 보여질 내용들을 선별하는 걸 가능하게 해줍니다.

Subpages

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 {{Talk:Pussycat/Let's delete Pussycat!}}. Comments posted in either talk page will be shown in both.

Special pages

Some pages on Special:Specialpages can be transcluded, e.g.:

Sample: {{Special:Newpages/3}} gives 3 new pages.

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

{{Special:RecentChanges|namespace=10|limit=5}}.

Alternatives to transclusion by template

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: {{subst:template name}}.

Labeled Section Transclusion

An extension called Labeled Section Transclusion enables marked sections of text to be transcluded.

Scribunto

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

Semantic 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.

Pages related to MediaWiki transclusion


Templates

See also