I am in the process of creating my first web app and I am at a point where I have some basic CRUD functionality. I got tired of looking at the default browser styling so I decided to use Twitter Bootstrap (TBS) to implement some basic styling. Once I started adding all the extra divs and classes required to implement TBS, I realized that this would be a real pain if I had to do this for every page in my site. I figured some sort of templating was the answer. I have never used a template engine but I think I have a very basic understanding of templating outside the scope of any particular templating engine. The two basic methods of templating that I think I understand are: 1) Using variables in the template; or 2) Using the find and replace method (which I believe Smarty uses if I’m not mistaken). However, all of the examples I’ve seen show a very basic HTML template with some very simple variable or search/replace methods. In my code though it doesn’t seem that simple. For instance, my page may start out with all of the TBS divs and other tags, followed by some PHP code to show query results, followed by more tags to close the TBS divs. Then I may have more PHP code followed by more HTML. In the variable replacement method of templating that I’ve seen, they simply replace a variable with some echoed text. But it’s not that easy when your PHP code is more complex.
[code]<?php include_once "includes/header.php" ?>
<?php include_once "includes/beginning_scripts.php" ?>PHP CODE HERE
</div><!--class="span3"-->
<div class="span3">
</div><!--class="span3"-->
PHP CODE HERE
</div><!--class="span8"-->
<div class="span2">
</div><!--class="span2"-->