[dokuwiki] Re: Why passing $renderer everywhere?

  • From: Andreas Gohr <andi@xxxxxxxxxxxxxx>
  • To: DokuWiki Mailinglist <dokuwiki@xxxxxxxxxxxxx>
  • Date: Thu, 4 Jul 2013 09:54:46 +0200

Hi,

> As far as I understand, most of functions that render something use existing 
> $renderer object and modify it instead of just returning string. As far as I 
> understand, the main reason of such behaviour is that $renderer contains not 
> only the text but also TOC and maybe something else.

The renderer may even contain something completely different. We have
different renderers, one for xhtml (the one you probably looked at)
but also one for extracting metadata or plugin renderers creating
OpenOffice documents for example.

> A piece of code backs up its previous $renderer, assigns current renderer to 
> $renderer, then calls some other methods that fill $renderer with content, 
> then restores the original value of $renderer.

What?? Where is this supposed to happen? Each instruction get handled
and passed to a rendering method (either core or plugin) this
rendering method gets the same instance of the current renderer and
modifies it to make sure its output is taken into account (by adding
to $doc, by creating new XML in the ODT or by calling a metadata
function for example).

> Why not return a new $renderer which will then be appended to the old one 
> with some method (which will hust append doc to doc, toc to toc, etc)?

Because rendering is not just appending text. It can be much more.

Andi
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: