[dokuwiki] Re: syntax plugins handle vs. render

  • From: Andreas Gohr <andi@xxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Fri, 22 Dec 2006 12:15:37 +0100

On Fri, 22 Dec 2006 01:31:51 -0600
"Martin Tschofen" <martin.tschofen@xxxxxxxxx> wrote:

> The plugin page mentions that when developing plugins it is best to
> do as much as possible in the handle function.
> I'm not sure I understand how it matters?

Because Parsing/Handling is cached seperately from Rendering. The
rendered output is more often obsoleted than the instruction set
generated in the first step. So your renderer may be called very often
even if the page it self wasn't changed.

> If I should do most of the work in the handle:
> Would it make sense then to process all info based on the found
> pattern into an object or array of some sort in the handle function.
> Then in the render function wrap the obj pieces around the content?

Exactly.


> I have a number of very similar syntaxes for this plugin.
> a) Is it better to create separate files for each syntax variation
> (right now I separate them out)
> b) To share common functions between these seperate files would it be
> possible to subclass each from a common plugin_syntax class that is
> based on syntax.pnp?

A subclass might be a good idea then. Avoiding code repetition is
always a good thing.

Andi

-- 
http://www.splitbrain.org
-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: