Modul:Transcluder/Doku
Dies ist die Dokumentationsseite für Modul:Transcluder
Usage[Bearbeiten | Quelltext bearbeiten]
https://www.mediawiki.org/wiki/Module:Transcluder
Modules[Bearbeiten | Quelltext bearbeiten]
The main entry point for modules is the <tvar name=1>get
</tvar> method.
get( 'Title' )
— <translate> Get the requested page (exact same result as normal transclusion)</translate>get( 'Title#' )
— <translate> Get the lead section of the requested page</translate>get( 'Title#Section' )
— <translate> Get the requested section or <tvar name=1>Vorlage:Tag</tvar> tag (includes any subsections)</translate>
<translate> <tvar name=1>Vorlage:Tag</tvar> and <tvar name=2>Vorlage:Tag</tvar> tags are handled [[<tvar name=3>Special:MyLanguage/Transclusion#Transclusion markup</tvar>|the usual way]] and there's also an optional second parameter to exclude various elements from the result:</translate>
get( 'Title#Section', { files = 0 } )
— <translate> Exclude all files</translate>get( 'Title#Section', { files = 1 } )
— <translate> Exclude all files except the first</translate>get( 'Title#Section', { files = 2 } )
— <translate> Exclude all files except the second</translate>get( 'Title#Section', { files = '1,2' } )
— <translate> Exclude all files except the first and second</translate>get( 'Title#Section', { files = '1-3' } )
— <translate> Exclude all files except the first, second and third</translate>get( 'Title#Section', { files = '1,3-5' } )
— <translate> Exclude all files except the first, third, fourth and fifth</translate>get( 'Title#Section', { files = -2 } )
— <translate> Exclude the second file</translate>get( 'Title#Section', { files = '-2,3' } )
— <translate> Exclude the second and third files</translate>get( 'Title#Section', { files = '-1,3-5' } )
— <translate> Exclude the first, third, fourth and fifth files</translate>get( 'Title#Section', { files = 'A.png' } )
— <translate> Exclude all files except <tvar name=1>A.png</tvar></translate>get( 'Title#Section', { files = '-A.png' } )
— <translate> Exclude <tvar name=1>A.png</tvar></translate>get( 'Title#Section', { files = 'A.png, B.jpg, C.gif' } )
— <translate> Exclude all files except <tvar name=1>A.png</tvar>, <tvar name=2>B.jpg</tvar> and <tvar name=3>C.gif</tvar></translate>get( 'Title#Section', { files = '-A.png, B.jpg, C.gif' } )
— <translate> Exclude <tvar name=1>A.png</tvar>, <tvar name=2>B.jpg</tvar> and <tvar name=3>C.gif</tvar></translate>get( 'Title#Section', { files = { [1] = true, [3] = true } } )
— <translate> Exclude all files except the first and third</translate>get( 'Title#Section', { files = { [1] = false, [3] = false } } )
— <translate> Exclude the first and third files</translate>get( 'Title#Section', { files = { ['A.png'] = false, ['B.jpg'] = false } } )
— <translate> Exclude <tvar name=1>A.png</tvar> and <tvar name=2>B.jpg</tvar></translate>get( 'Title#Section', { files = '.+%.png' } )
— <translate> Exclude all files except PNG files (see [[<tvar name=1>Special:MyLanguage/Extension:Scribunto/Lua reference manual#Patterns</tvar>|Lua patterns]])</translate>get( 'Title#Section', { files = '-.+%.png' } )
— <translate> Exclude all PNG files</translate>
<translate> The very same syntax can be used to exclude many other elements:</translate>
get( 'Title#Section', { sections = 0 } )
— <translate> Exclude all subsections</translate>get( 'Title#Section', { sections = 'History, Causes' } )
— <translate> Exclude all subsections except '<tvar name=1>History</tvar>' and '<tvar name=2>Causes</tvar>'</translate>get( 'Title#Section', { lists = 1 } )
— <translate> Exclude all lists except the first</translate>get( 'Title#Section', { tables = 'stats' } )
— <translate> Exclude all tables except the one with id '<tvar name=1>stats</tvar>'</translate>get( 'Title#Section', { paragraphs = '1-3' } )
— <translate> Exclude all paragraphs except the first, second and third</translate>get( 'Title#Section', { references = 0 } )
— <translate> Exclude all references</translate>get( 'Title#Section', { categories = '0' } )
— <translate> Exclude all categories</translate>get( 'Title#Section', { templates = '-.+infobox' } )
— <translate> Exclude infobox templates</translate>get( 'Title#Section', { parameters = 'image' } )
— <translate> Exclude all parameters from all templates except the one named '<tvar name=1>image</tvar>'</translate>
<translate> Options can be combined at will.</translate> <translate> For example:</translate>
get( 'Title#Section', { sections = 0, files = 1, paragraphs = '1-3' } )
— <translate> Exclude all subsections, all files except the first, and all paragraphs except the first three</translate>
<translate> You can also get only some elements like so:</translate>
get( 'Title#Section', { only = 'files' } )
— <translate> Get only the files</translate>get( 'Title#Section', { only = 'lists', lists = 1 } )
— <translate> Get only the first list</translate>get( 'Title#Section', { only = 'tables', tables = 'stats' } )
— <translate> Get only the table with id '<tvar name=1>stats</tvar>'</translate>get( 'Title#Section', { only = 'paragraphs', paragraphs = '1,3-5' } )
— <translate> Get only the first, third, fourth and fifth paragraph</translate>get( 'Title#Section', { only = 'templates', templates = 'Infobox' } )
— <translate> Get only the infobox</translate>get( 'Title#Section', { only = 'parameters', parameters = 'abstract', references = 0 } )
— <translate> Get only the parameter called 'abstract' and remove all the references from it</translate>
<translate> The output can be further modified with a few special options:</translate>
get( 'Title#Section', { noFollow = true } )
— <translate> Don't follow redirects</translate>get( 'Title#Section', { linkBold = true } )
— <translate> Link the bold title or synonym near the start of the text</translate>get( 'Title#Section', { noBold = true } )
— <translate> Remove bold text</translate>get( 'Title#Section', { noComments = true } )
— <translate> Remove comments</translate>get( 'Title#Section', { noLinks = true } )
— <translate> Remove all links</translate>get( 'Title#Section', { noSelfLinks = true } )
— <translate> Remove self links</translate>get( 'Title#Section', { noNonFreeFiles = true } )
— <translate> Remove non-free files (currently identified by having the words 'non-free' in their local description or at Commons)</translate>get( 'Title#Section', { noBehaviorSwitches = true } )
— <translate> Remove [[<tvar name=1>Special:MyLanguage/Help:Magic words#Behavior switches</tvar>|behavior switches]] such as <tvar name=2>__NOTOC__
</tvar></translate>get( 'Title#Section', { fixReferences = true } )
— <translate> Prefix reference names with 'Title ' to avoid name conflicts when transcluding and rescue references defined outside the requested section to avoid undefined reference errors</translate>
<translate> Besides the <tvar name=1>get
</tvar> method, the module exposes several other methods to get specific parts of the wikitext.</translate>
<translate> This allows other modules to combine elements in more advanced ways.</translate>
<translate>
Templates[Bearbeiten | Quelltext bearbeiten]
</translate>
<translate> The main entry point for templates is the <tvar name=1>main
</tvar> method.</translate>
<translate> It's essentially a wrapper of the <tvar name=1>get
</tvar> method to make it usable for templates.</translate>
<translate> See the documentation of the <tvar name=1>get
</tvar> method for more details and options.</translate>
{{#invoke:Transcluder|main|Title}}
— <translate> Transclude the requested page</translate>{{#invoke:Transcluder|main|Title#}}
— <translate> Transclude the lead section of the requested page</translate>{{#invoke:Transcluder|main|Title#Section}}
— <translate> Transclude the requested section or <tvar name=1>Vorlage:Tag</tvar> tag (includes any subsections)</translate>{{#invoke:Transcluder|main|Title#Section|sections=0}}
— <translate> Transclude the requested section, excluding subsections</translate>{{#invoke:Transcluder|main|Title|only=files|files=1}}
— <translate> Transclude only the first file of the page</translate>{{#invoke:Transcluder|main|Title#Section|only=tables|tables=2}}
— <translate> Transclude only the second table of the requested section</translate>{{#invoke:Transcluder|main|Title#|only=paragraphs|linkBold=yes}}
— <translate> Transclude only the paragraphs of the lead section and link the bold text</translate>