This page uses the default.html template and draws its main content from the content.html file.


At its most basic, Contemplate separates design from content. But if your site involves any significant programming, it's a good idea to separate that, too, and use Contemplate to bring all three parts together. In this page, the content (text and layout) comes from content/main.html, but the functionality (querying a user database and looping through the results) comes from scripts/functionality.php.

Since the scripts folder is not part of Contemplate's basic functionality, it is listed in the READ_FILES_FROM setting in config/constants.php so that Contemplate is authorized to read it.

Once embedded into the page, the script has access to the content, so it can manipulate it and merge data into it before displaying it. This includes taking the table below (which has a single, empty row in the content file) and outputting a new row for each user.

Username Name City
jdoe John Doe Chicago
jdow Jane Dow New York
jdill Jill Dill Los Angeles

The script can also generate individual pieces of data and merge them into the content file. For example, this date is calculated by the script: Aug 19, 2019. If you look in the content file, you'll just see the variable $date.