I think its important that templates work via the filesystem at the core to make this just one step futher a great CMS
Here’s a plugin to do just that. This way we can both have it the way we like it
Create a new plugin, name it whatever you want, check the OnLoadWebDocument checkbox in the System Events tab, and copy/paste the following code into the plugin’s Plugin Code field:
// get the template ID
$templateId = $modx->documentObject['template'];
// get the template name
$rs = $modx->db->select('templatename', $modx->getFullTableName('site_templates'), 'id = ' . $templateId);
$tplName = $modx->db->getValue($rs);
// get template file or nothing
$filename = MODX_BASE_PATH . $path . $tplName . '/' . $tplName . $ext;
$tpl = @file_get_contents($filename);
// load template into parser
$modx->documentContent = $tpl;
In the Configuration tab, add this parameter:
&path=Path;text;assets/templates/ &ext=Extension;test;.tpl
Save the plugin. Now you can edit the Path and Extension configuration parameters as you wish.
Create a new template, just giving it a name (no spaces in the name) but no content. Then in assets/templates create a directory with the exact same name, and put your template file in it with the same name + .tpl (or whatever extension you set in the plugin configuration). The template’s directory and file name must match exactly the template name! For example, a template named MyTemplate it would look like this
MyTemplate/MyTemplate.tpl
This could probably use some bells and whistles, such as running it through a function to allow spaces and special characters in the template’s name or loading a default template if the one expected can’t be loaded for some reason.