User:Barre/MediaWiki/Extensions/kw include file

From KitwarePublic
Jump to navigationJump to search

<kw_bread_crumbs>prefix=» |small=1|bgcolor=F9F9F9|trim_prefix=User:|on_top_hack=1</kw_bread_crumbs> <kw_include_file>url=*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb%7Cpre=0%7Cwiki_markup=1%7Ccollapse_par=1%7Cpreg_match=/.*\/\*\s*(==.*?)^\*\//sm</kw_include_file>


First let's include a small file:

<kw_include_file>url=*checkout*/README.txt?root=kwGrid</kw_include_file> rendered as: <kw_include_file>url=*checkout*/README.txt?root=kwGrid</kw_include_file>

Now for something more complex: note that the whole documentation above this section is included straight from the extension code itself ! Here is how it is done:


The hairy URL is followed by several options. The pre=0 parameter means that we do not want the text to be inserted verbatim inside PRE.../PRE tags. The wiki_markup=1 parameter specifies that the text is to be interpreted as Wiki markup. The (optional) collapse_par=1 parameter helps the Wiki engine by collapsing lines into paragraphs. The preg_match parameter specificies a regular expression that is used to extract only the documentation portion of the remote file: nothing fancy here, we are just looking for the string starting with == right inside a PHP comment /* ... */.

You can also include the contents of a wiki page (in that example, the User:Barre page):