Theoretical question.
I'm working on replacing a software system that uses templates stored in the DB to output site pages.
There's a "basic template" (or two or three) that's generally HTML with some 'marker tags' in it. The marker tags are replaced by other types of code "modules" that are also in the DB ... maybe HTML, maybe PHP or JS or even Flash objects, I guess.
I don't know for sure how the old system does it because that part of the system is "encrypted", but I'm currently leaning very heavily towards the theory that they're parsing the code, str_replace()ing the marker tags with the DB data, and then running the whole mess through [man]eval/man.
Presumptively the whole system exists so a non-programmer can add create pages simply by typing content into a WYSIWYG or pasting copied code into a form and saving it with a unique name (that creates the marker tag referred to above).
I've been able to duplicate this sort of functionality with this as the output script:
require_once("config.php");
require_once($Myconfig['class_path'] . "/ParseTemplate.class.php");
//I have this template stored in a file for testing, but it could come from DB instead
$template = file_get_contents($Myconfig['server_path'] . "/my_templates/basic.1.html");
$parser = new ParseTemplate($template);
$code = $parser->replaceTags();
$code = ltrim($code, "<"."?php");
$code = rtrim($code, "?".">");
echo eval($code);
Of course, the code's really kind of irrelevant; the question is how should the system be designed?
Do I want to keep this system using this paradigm? Or something different, like saving the modules and templates as files ... ?
Any thoughts? :-)