Module:Transcluder/doc

This page is a translated version of the page Module:Transcluder/doc and the translation is 68% complete.

このモジュールは、汎用の参照読み込みエンジンであり、ページの任意の部分を参照読み込みでき、通常の参照読み込みでは提供されない多くのオプションがあります。

使用法

モジュール

モジュールのメインのエントリー ポイントは get メソッドです。

  • get( 'Title' ) — リクエストされたページを取得 (通常の参照読み込みとまったく同じ結果)
  • get( 'Title#' ) — リクエストされたページの導入節を取得
  • get( 'Title#Section' ) — リクエストされた節または ‎<section> タグ (下位節を含む) を取得

‎<noinclude> および ‎<onlyinclude> タグは通常の方法で処理されますが、結果からさまざまな要素を除外する省略可能な 2 番目のパラメーターもあります:

  • get( 'Title#Section', { files = 0 } ) — すべてのファイルを除外
  • get( 'Title#Section', { files = 1 } ) — 最初以外のすべてのファイルを除外
  • get( 'Title#Section', { files = 2 } ) — 2 番め以外のすべてのファイルを除外
  • get( 'Title#Section', { files = '1,2' } ) — 最初と 2 番め以外のすべてのファイルを除外
  • get( 'Title#Section', { files = '1-3' } ) — 最初から 3 番め以外のすべてのファイルを除外
  • get( 'Title#Section', { files = '1,3-5' } ) — 最初から 3 番めと5番め以外のすべてのファイルを除外
  • get( 'Title#Section', { files = -2 } ) — 2 番めのファイルを除外
  • get( 'Title#Section', { files = '-2,3' } ) — 2 番めと 3 番めのファイルを除外
  • get( 'Title#Section', { files = '-1,3-5' } ) — 最初と 3 番めから 5 番目のファイルを除外
  • get( 'Title#Section', { files = 'A.png' } ) — A.png 以外のすべてのファイルを除外
  • get( 'Title#Section', { files = '-A.png' } ) — A.png を除外
  • get( 'Title#Section', { files = 'A.png, B.jpg, C.gif' } ) — A.png、B.jpg、C.gif 以外のすべてのファイルを除外
  • get( 'Title#Section', { files = '-A.png, B.jpg, C.gif' } ) — A.png、B.jpg、C.gif を除外
  • get( 'Title#Section', { files = { [1] = true, [3] = true } } ) — 最初と 3 番め以外のすべてのファイルを除外
  • get( 'Title#Section', { files = { [1] = false, [3] = false } } ) — 最初と 3 番めのファイルを除外
  • get( 'Title#Section', { files = { ['A.png'] = false, ['B.jpg'] = false } } ) — A.png と B.jpg を除外
  • get( 'Title#Section', { files = '.+%.png' } ) — PNG ファイル以外のすべてのファイルを除外 (Lua パターンを参照)
  • get( 'Title#Section', { files = '-.+%.png' } ) — すべての PNG ファイルを除外

まったく同じ構文を使用して、他の多くの要素を除外できます:

  • get( 'Title#Section', { sections = 0 } ) — すべての下位節を除外
  • get( 'Title#Section', { sections = 'History, Causes' } ) — 「History」「Causes」以外のすべての節を除外
  • get( 'Title#Section', { lists = 1 } ) — 最初以外のすべての節を除外
  • get( 'Title#Section', { tables = 'stats' } ) — 「stats」という ID の表以外のすべての表を除外
  • get( 'Title#Section', { paragraphs = '1-3' } ) — 最初から 3 番め以外のすべての段落を除外
  • get( 'Title#Section', { references = 0 } ) — すべての参照を除外
  • get( 'Title#Section', { categories = '0' } ) — すべてのカテゴリを除外
  • get( 'Title#Section', { templates = '-.+infobox' } ) — 基礎情報テンプレートを除外
  • get( 'Title#Section', { parameters = 'image' } ) — 「image」という名前のテンプレート以外のすべてのテンプレートからすべてのパラメーターを除外

オプションは自由に組み合わせられます。 例:

  • get( 'Title#Section', { sections = 0, files = 1, paragraphs = '1-3' } ) — すべての下位節、最初以外のすべてのファイル、最初の 3 つ以外のすべての段落を除外

以下のように一部の要素のみを取得することもできます:

  • get( 'Title#Section', { only = 'files' } ) — ファイルのみを取得
  • get( 'Title#Section', { only = 'lists', lists = 1 } ) — 最初の一覧のみを取得
  • get( 'Title#Section', { only = 'tables', tables = 'stats' } ) — 「stats」という ID の表のみを取得
  • get( 'Title#Section', { only = 'paragraphs', paragraphs = '1,3-5' } ) — 最初と 3 番めから 5 番めの段落のみを取得
  • get( 'Title#Section', { only = 'templates', templates = 'Infobox' } ) — 基礎情報ボックスのみを取得
  • get( 'Title#Section', { only = 'parameters', parameters = 'abstract', references = 0 } )Get only the parameter called 'abstract' and remove all the references from it

The output can be further modified with a few special options:

  • get( 'Title#Section', { noFollow = true } )Don't follow redirects
  • get( 'Title#Section', { linkBold = true } )Link the bold title or synonym near the start of the text
  • get( 'Title#Section', { noBold = true } )Remove bold text
  • get( 'Title#Section', { noComments = true } )Remove comments
  • get( 'Title#Section', { noLinks = true } )Remove all links
  • get( 'Title#Section', { noSelfLinks = true } )Remove self links
  • get( 'Title#Section', { noNonFreeFiles = true } )Remove non-free files (currently identified by having the words 'non-free' in their local description or at Commons)
  • get( 'Title#Section', { noBehaviorSwitches = true } )Remove behavior switches such as __NOTOC__
  • get( 'Title#Section', { fixReferences = true } )Prefix reference names with 'Title ' to avoid name conflicts when transcluding and rescue references defined outside the requested section to avoid undefined reference errors

Besides the get method, the module exposes several other methods to get specific parts of the wikitext. This allows other modules to combine elements in more advanced ways.

テンプレート

The main entry point for templates is the main method. It's essentially a wrapper of the get method to make it usable for templates.

See the documentation of the get method for more details and options.

  • {{#invoke:Transcluder|main|Title}}Transclude the requested page
  • {{#invoke:Transcluder|main|Title#}}Transclude the lead section of the requested page
  • {{#invoke:Transcluder|main|Title#Section}}Transclude the requested section or ‎<section> tag (includes any subsections)
  • {{#invoke:Transcluder|main|Title#Section|sections=0}}Transclude the requested section, excluding subsections
  • {{#invoke:Transcluder|main|Title|only=files|files=1}}Transclude only the first file of the page
  • {{#invoke:Transcluder|main|Title#Section|only=tables|tables=2}}Transclude only the second table of the requested section
  • {{#invoke:Transcluder|main|Title#|only=paragraphs|linkBold=yes}}Transclude only the paragraphs of the lead section and link the bold text

関連項目