[pmwiki-devel] Suggestions for code approach

DaveG pmwiki at solidgone.com
Thu Jul 10 08:30:39 CDT 2008


I'm writing a cookbook that outputs some HTML. At this point there are 
two basic options for the style of HTML output that are required, one 
using DIVs and the other using lists. Both are needed to support various 
3rd party extensions.

Both styles need a wrapper object, and html for each 'row' of data.
DIV style sample:
<div id="parameter" class="wrapper">
    <div class="row">xxxx</div>
    <div class="row">xxxx</div>
</div>

List style sample:
<ul id="parameter" class="wrapper">
    <li class="row">xxxx</li>
    <li class="row">xxxx</li>
</ul>

It's possible that there may be other output styles needed in the 
future, although these are not identified at this point, and may never 
arise.

I'm seeking some input and ideas around the two approaches below, or 
additional approaches people have.

1] Simply provide a switch parameter, and code the two options into the 
cookbook. ie:

if (output_Style == "div") {
    $output_style_wrapper="div";
    $output_style_row  ="div";
} else {
    $output_style_wrapper="ul";
    $output_style_row  ="li";
}
{generate output with variables above}

To me this is a simple solution, and doesn't try to pre-guess future 
requirements. However, it's not very 'clean', and *might* get messy later.

2] Use some form of FormatStr, in the same way PmWiki uses for things 
like anchor formatting. This seems like a better option. It would seem 
like I'd need two format strings, one for the wrapper, and one for the 
'row' level. Could someone give me some guidance on how to accomplish 
this in PmWiki. How do I setup a new 'format string'? Do I need two 
strings (one for wrapper and one for row), or can I get by with one?

Thanks for the help, and thoughts.

  ~ ~ Dave



More information about the pmwiki-devel mailing list