Beware the Jabberwock, my son!
The jaws that bite, the claws that catch!
Beware the Jubjub bird, and shun
The frumious Bandersnatch!
WHAT'S IN THIS CHAPTER?
Creating an image gallery using Lightbox
Integrating chosen template engines with frameworks
Pros and cons of using template engines
Overview of popular template engines
Previous chapters discussed frameworks' innards; this chapter focuses on the presentation layer instead. So what are these template engines, and why are they so important? In web development, PHP code processes all data, so it's responsible for the business logic. The view layer represented by template engines is the presentation part of your site. A template engine allows you to develop websites with various different layouts or themes for the same core functionality.
Template engines are very popular tools among PHP projects that do not use any frameworks. Despite their popularity however, they are not often used along with web frameworks. In this chapter, we will explain why it is so and show a few tricks to make them get along with each other.
The following script renders an index page. It uses some PHP functions to generate the page content intertwined with HTML blocks. (This is a programming style from the year 2000, when PHP was a new thing altogether.)
<?php $head_title = 'Title'; $block_name ='News block'; display_content(); function_1(); function_2(); ?> <html> <head> ...