One of a series of test instances for migrating the Koha Wiki MediaWiki database.
For the current Koha Wiki, visit https://wiki.koha-community.org .Template:Excerpt/sandbox
| This is the template sandbox page for Template:Excerpt (diff). See also the companion subpage for test cases. |
| This template uses Lua: |
Lua error in Module:TNT at line 157: attempt to index field 'data' (a nil value).
This template is used for transcluding part of an article into another article. This template extends the capabilities of the built-in Help:Labeled section transclusion function.
Usage
Basic usage
{{Excerpt|Title of the article}}— Transclude the lead section of an article (example).{{Excerpt|Title of the article|Title of the section}}— Transclude a specific section excluding any subsections (example).
Parameters
1orarticle— Title of the article to transclude. Only required parameter. If no other parameters are used, the lead section will be transcluded (example).2orsection— Title of the section to transclude (example).only— Reduce the transcluded content to this element onlyonly=tableoronly=tables— Transclude only the tables of the requested section (example).only=listoronly=lists— Transclude only the lists of the requested section (example).only=fileoronly=files— Transclude only the files of the requested section, optionally cherry-picked with thefilesparameter (example).
fragment— Name of the fragment to transclude. Must be marked with<section begin=Name of the fragment/>and<section end=Name of the fragment/>in the transcluded article (example).this— Change the initial text of the hatnote. For example, if the transcluded content is a gallery, you can setthis=This gallery isso that the hatnote reads "This gallery is an excerpt from..." (example).nohat— Hide the hatnote "This section is an excerpt from..."paragraphs— Specify the paragraphs to transclude. For example1-3,5will transclude paragraphs 1, 2, 3 and 5. By default all paragraphs are transcluded. Notice that if the paragraph order changes in the source article, the transcluded paragraphs will change too and without any notice, so use with caution. Doesn't work withfragment.files— Specify the files to transclude. For example1-3,5will transclude files 1, 2, 3 and 5. By default only the first file is transcluded. Doesn't work withfragment.indicator— Determines whether to show a vertical bar along the excerpt to indicate where it starts and where it ends. By default none is shown. Set toyesto cause it to show.references— Determines whether to transclude references or not. By default all references are transcluded. Set tonoto prevent it.tables— Determines whether to transclude tables or not. By default all tables are transcluded. Set tonoto prevent it.subsections— Use together withsectionto transclude the entire section including any subsections. Notice that if the transclusion is done from a section level 3, and the transcluded subsections are level 3 too, then the transcluded subsections will show with the same hierarchy as the transcluding section, which is probably not desirable, so use with caution.tag— By default the excerpt is wrapped with<div>tags. Set tospanto wrap it with<span>tags instead.
Replacing Template:Main
Sections are often summaries of more precise subarticles (generally linked with Template:Main). Sometimes it's convenient to replace such sections for excerpts of the subarticles, after merging the original content of the section (if any) in the subarticle. This improves both the subarticle and the section, reduces maintenance, drives contributors to collaborate, etc.
An efficient way to proceed is:
- Open the section in one tab and the subarticle in another.
- Edit both.
- Copy the text of the section and paste it below the lead section of the subarticle.
- Delete repeated content and adjust using common sense.
- Save the changes in the subrticle with an edit summary like: Bring content from [[Article]].
- Back to the section, delete all content and replace it for an excerpt of the subarticle.
- Save the changes in the section with an edit summary like: Move content to [[Subarticle]] and leave an excerpt.
Compared to #section
For simple cases of transcluding sections of articles, the Template:Pf, Template:Pf, and Template:Pf (abbreviated Template:Pf, Template:Pf, and Template:Pf)) parser functions can be used instead of this template. Template:Pf will transclude the section of "article" with the header "section", and Template:Pf will transclude the lead section of "article". Excerpting only specific paragraphs can be done by marking up the source article with <section>...</section> tags and using Template:Pf to transclude those fragments, which is equivalent to using the |fragment= parameter with this template. <lsth>...</lsth> can also be used to transclude everything but those fragments.
The text will not be trimmed of excess whitespace, there will not be a header (equivalent to |nohat=yes, and all files, templates, tables, references, and subsections will be included unless the source article is marked up with <section>...</section>, <noinclude>...</noinclude>, or <onlyinclude>...</onlyinclude> tags. Self links will appear in bold.
Examples
Lead section
{{Excerpt|Science}}
Script error: No such module "Excerpt/templates". Template:Sources-talk
Specific section
{{Excerpt|Science|Branches of science}}
Script error: No such module "Excerpt/templates". Template:Sources-talk
Table only
{{Excerpt|Science|Branches of science|only=table}}
Script error: No such module "Excerpt/templates".
File only
{{Excerpt|Science|19th century|only=file|files=2}}
Script error: No such module "Excerpt/templates".
List only
{{Excerpt|Indian philosophy|Orthodox schools|only=list}}
Script error: No such module "Excerpt/templates". Template:Sources-talk
Specific fragment
{{Excerpt|2020 Republican Party presidential primaries|fragment=declared|this=These tables are}}
Script error: No such module "Excerpt/templates". Template:Sources-talk Template:Sources-talk
See also
- Wikipedia:Excerpts
- Category:Articles with excerpts, or Pages that link to "Template:Excerpt" (articles) (unsorted)
- Category:Articles with broken excerpts
- Help:Labeled section transclusion – A more efficient method for simple section transclusions
- Wikipedia:Transclusion#Selective transclusion – how to transclude one or more sections of an article or project page into another
- {{Transcluded section}} – creates hatnote but does not transclude the section
- {{Transcluding article}} – transcludes one or more entire pages
- meta:Grants:Project/Rapid/Sophivorus/Excerpts - Grant to spread excerpts to various Wikipedias
Template data
This template is used for transcluding part of an article into another article.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Article | 1 article | Title of the article to transclude
| Page | required |
| Section | 2 section | Title of the section to transclude
| String | optional |
| Only | only | Reduce the transcluded content to this element only
| String | optional |
| Fragment | fragment | Name of the fragment to transclude
| String | optional |
| This | this | Change the initial text of the hatnote
| String | optional |
| No hatnote | nohat | Whether to remove the hatnote
| Boolean | optional |
| Indicator | indicator | Whether to indicate the start and finish of the excerpt
| Boolean | optional |
| Paragraphs | paragraphs | What paragraphs to transclude
| String | optional |
| Files | files | What files to transclude
| String | optional |
| Tables | tables | Determines whether to transclude tables or not
| Boolean | optional |
| References | references | Determines whether to transclude references or not
| Boolean | optional |
| Subsections | subsections | Whether to transclude the subsections of the requested section
| Boolean | optional |
| Tag | tag | Allows use of "span" rather than "div" for when you don't want a line break before or after the excerpt
| String | optional |
| The above documentation is transcluded from Template:Excerpt/doc. (edit | history) Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. Please add categories to the /doc subpage. Subpages of this template. |