Archive for February 23rd, 2005
separate template from code
February 23rd, 2005
when you do serious coding, it’s always a good idea to separate your layout design (template) from your logic code. i’m at the beginning stage rebuilding dmb. one thing i want to do very badly is to get rid of all templates in the database. every time i load a template right now it causes me a query. i want to store my templates in files because file_get_contents is less expensive than a query. and i just figured out a very easy way to do that.
store your template in a file. it can be html, text or php, whatever suits your need.
put this in your html file, name it “test.html”
this is so $test
and then use the code below:
<?php
$test = "cool";
$meep = file_get_contents("test.html");
eval("\$meep = \"$meep\";");
echo $meep;
?>
and it will print out “this is so cool” ^_^

