A wiki with very good templating is WiClear:
http://wiclear.free.fr/
While WiClear's templating kicks DokuWiki thoroughly, DokuWiki happens to be a much better Wiki :-)
The way WiClear does it's template is by providing a couple of basic functions that drive the wiki, and then the template is a full html document with a few <?php wiclear_this(); ?> and <?php wiclear_that(); ?> calls to do the wiki stuff.
I think that DokuWiki could easily be moved to a similar model. The key functions to reexamine are all called from doku.php:
//start output
if(substr($ACT,0,6) != 'export') html_header();
if(html_acl($permneed)){
if($ACT == 'edit'){
html_edit();
}elseif($ACT == $lang['btn_preview']){
html_edit($TEXT);
html_show($TEXT);
}elseif($ACT == 'wordblock'){
html_edit($TEXT,'wordblock');
}elseif($ACT == 'search' && !empty($QUERY)){
html_search();
}elseif($ACT == 'revisions'){
html_revisions();
}elseif($ACT == 'diff'){
html_diff();
}elseif($ACT == 'recent'){
html_recent();
}elseif($ACT == 'index'){
html_index($IDX);
}elseif($ACT == 'backlink'){
html_backlinks();
}elseif($ACT == 'conflict'){
html_conflict(con($PRE,$TEXT,$SUF),$SUM);
html_diff(con($PRE,$TEXT,$SUF),false);
}elseif($ACT == 'locked'){
html_locked($lockedby);
}elseif($ACT == 'login'){
html_login();
}elseif($ACT == 'register' && $conf['openregister']){
html_register();
}elseif($ACT == 'export_html'){
html_head();
print "<body>\\n";
print parsedWiki($ID,$REV,false);
print "</body>\\n</html>\\n";
}elseif($ACT == 'export_raw'){
header("Content-Type: text/plain");
print rawWiki($ID,$REV);
}else{
$ACT='show';
html_show();
}
}
if(substr($ACT,0,6) != 'export') html_footer();
What I think we can do is to put the big elseif thinger a) into a case statement, they're often easier to read (but that's a religious issue, so moving on...) and to b) wrap the elseif block into a function. What we're left with is:
if (!export) html_header();
html_actions(); // I am new to this comment
if (export) html_head();
html_show();
if (!export) html_footer();
I don't think it's hard to imagine that from there we could do this:
if (export)
include(themes/export.php);
else
include(themes/$config_theme.php);
And in the theme files, all the of the contents of html_header, html_footer and dumped raw into the file (since they are what needs to be themed in the first place!) and then just two calls to html_actions() and html_show() does the trick!
Oh, and I should mention that I'm more than willing to do the code :-)