Edgewall Software

Changes between Version 36 and Version 37 of TracDev/Proposals/AdvancedWikiFormatting


Ignore:
Timestamp:
Jul 15, 2010, 4:44:52 PM (14 years ago)
Author:
Christian Boos
Comment:

#Transclusion more details about the proposed syntax and behavior

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/Proposals/AdvancedWikiFormatting

    v36 v37  
    174174The basic idea is that the content of a Wiki page can be reused and displayed in some other places, typically another wiki page which aggregates the content of several other pages.
    175175
    176 One typical use case is to transclude a parametric page used as a template (`Template:` namespace - #3021). In order to be really useful, this implies having wiki variables, and some control structures (at the very least simple conditionals).
     176One typical use case is to transclude a parametric page used as a template (`Template:` namespace - #3021). In order to be really useful, this implies having wiki variables, and some control structures (at the very least simple conditionals, and [MediaWiki:Help:Template#Control_template_inclusion noinclude/includeonly] blocks).
    177177
    178178Also, we could have ways to include only //parts// of a page, by using some kind of selector mechanism (XPath or CSS inspired?) on the WikiDom tree.
     
    191191}}}
    192192}}}
     193
    193194Alternatively, the default content of the include processor could be made available to the  wiki variables present in the template in a special variable, e.g. "INCLUDE_CONTENT".
    194195
    195 Variables expansion could also be done using a dedicated syntax (e.g. `@INCLUDE_CONTENT@`, like [MoinMoin:HelpOnVariables MoinMoin] or [http://www.dokuwiki.org/plugin:templater plugin:templater] in dokuwiki), (to be continued...)
     196Variable expansion could also be done using a dedicated syntax (e.g. `@INCLUDE_CONTENT@`, like [MoinMoin:HelpOnVariables MoinMoin] or [http://www.dokuwiki.org/plugin:templater plugin:templater] in dokuwiki), the `{{{...}}}` style of MediaWiki conflicts with our inline verbatim style.
     197
     198The Template:ReleaseInfo page would have the following content:
     199{{{
     200 Version:: @version|unknown@
     201 {{{#!if defined="description"
     202 Description:: @description@
     203 }}}
     204}}}
     205
     206Instead of `#!param`, we could also use `!#define` to create a variable that could be used in the document itself, or rather in the current scope.
     207
     208A define would not only work for defining variables but also for defining in-document templates ("macros"), unifying variables and templates.
     209
     210The example "Template:ReleaseInfo" above could be inlined:
     211{{{
     212{{{#!define name="ReleaseInfo"
     213 Version:: @version|unknown@
     214 {{{#!if defined="description"
     215 Description:: @description@
     216 }}}
     217}}}
     218}}}
     219And would be called:
     220{{{
     221{{{#!include name=".#ReleaseInfo" version="2.0" description="not there yet"
     222}}}
     223}}}
     224or simpler:
     225 - `[[Include(#ReleaseInfo, version=2.0, description=not there yet)]]`
     226 - `{{#ReleaseInfo|version=2.0|description=not there yet}}` (MediaWiki:Help:Template)
     227Note that `.#abc` and `#abc` are targeting the same node.
     228
     229"Define" could also be used for much small repetitive text, like repetitive URLs, when one doesn't want to define an InterWiki prefix for it, e.g.
     230 -
     231`[[Define(issue=http://bugs.python.org/issue@1@)]]` and `{{issue|1234}}`
     232 - `@issue=http://bugs.python.org/issue{{1}}@` (?)
     233 - `@issue=http://bugs.python.org/issue@` and `@issue@1234` (?)
     234
     235In summary, we would have the following constructions:
     236||                 ||=     Define      =||=     Include     =||
     237{{{#!th rowspan=2
     238Dedicated Wiki Syntax
     239}}}
     240|| `@<name>=value@` ? || `@<name>@` or `@<name>|default@` ||
     241|| `{{<name>=value}}` ? || `{{<name>}}` or `{{<name>|p1|p=val}}` ||
     242||= Macro          ||\
     243||                    `[[Define(<name>=<content>)]]` ||\
     244||                                `[[Include(<name>)]]` ||
     245||= WikiProcessor  ||\
     246{{{#!td
     247 {{{
     248 {{{#!define name="<name>" p="default"
     249 ...
     250 }}}
     251 }}}
     252}}}
     253{{{#!td
     254 {{{
     255 {{{#!include name="<name>" p="value"
     256 ...
     257 }}}
     258 }}}
     259}}}
     260Defines should of course be able to contain anything, including other transclusions. Includes can contain defines, as a way to pass complex input parameters which can also contain anything, including other transclusions.
     261
     262A technical difficulty with the short form for transclusion `{{...}}` is the need to handle the nesting of `{{...}}` pairs, to allow for multiple level of expansion, like shown in [http://meta.wikimedia.org/wiki/Help:Advanced_templates advanced templates] in MediaWiki.
     263
     264The `<name>` parameter given to includes should itself be subject to expansion , and if this corresponds to an unbound variable, the inclusion will be dynamic (parsing deferred to the formatting stage).
     265//Or should parsing always be deferred?//.
     266
     267Recursion should be detected (//trying to include `<name>` when `<name>` is already in the stack of includes//) and prevented (//as if `<name>` was missing, i.e. replaced by nothing or the given `default` value//).
     268
     269Finally, the transclusion should not be restricted to Wiki pages, but should ultimately be able to include other Trac resources (e.g. milestone or ticket descriptions, (parts of) files from the repository, etc.)
    196270
    197271See also #4468.