User:Dantman/Skinning system/Template syntax/templates + php
| This page is a part of Daniel Friesen's Skinning system plans. This page details an idea which was later superseded or re-thought. |
Originally the idea was there would be a template api and a php api. However after experimenting with lang="mw:user" and seeing the ugliness that a simple <script> expands to I've found really good quality skinning is in some cases close to impossible to the php api or just plain too ugly (lang="mw:user"'s intelligent stripping of lang attributes can't be done reliably in a way compatible with improvements to our multilang support the way it can with templates, and I really don't like continuing the ugly way we do script tags).
I do have one potential idea to get the flexibility of having a php api and a template api, while getting the advantages of both, not losing the advantages of the templating when using php. Instead of defining a template to use for the body, the body method is always used, and it's "that" output that gets passed through the template. So instead of doing <?php if ( test you can't make in template ) { ?><div<?php $this->lang('user') ?>>...</div><?php } ?> you use <?php if ( test you can't make in template ) { ?><div lang="mw:user">...</div><?php } ?>. If you don't need any special php processing the default body method will just output the contents of the template so it will be handled.
<?php // [...] public function body( $w ) { global $wgUser; ?> <div id="content" lang="mw:page"> <a id="top"></a> <div id="siteNotice" mw:if="sitenotice"><mw:sitenotice /></div> <h1 id="firstHeading" class="firstHeading"><mw:title /></h1> <div id="bodyContent"> <?php echo $wgUser->edits(); ?> <mw:region name=body size=wide primary> <div class="visualClear"></div> </div> </div> <?php } // [...]
I may have to mull some of this over though. There were some ideas like the extraction of region information from a template. I need to examine if there is anything in the way of providing that ability by doing it this way.