Which PHP Template Engine syntax is best to use?

frameworks, html, parsing, php

Solution

The best option us to use PHP itself for templating, kinda like described in this article.

As for views. I think you are suffering from classical Rails delusion. Views are meant to be classes/objects/instances, which contain presentation logic and are responsible for producing the response to user. It might mean arranging HTML output from multiple templates or just sending a HTTP header as only response. Or maybe some JSON file, or XML.

Problem

Okay so I am developing an advanced framework in PHP using MVC and want to know the best way to format the Views with dynamic data to be parsed by the PHP. Currently I am using this format: Format of Controller loading a View ``` $vars = array(); $vars['EXAMPLE_TEXT'] = "Hello World!"; $this->load->View("view_name", $vars); ``` Where vars is an array of strings to be passed into the view using the key to identify it in the View. Format of the "view_name" view. ``` <b>{EXAMPLE_TEXT}</b> ``` would just show the text: Hello World! The problem But as I am starting to use complex elements from databases (using foreach loops) I can not find a suitable syntax for the view, while keeping it nice for developers and keeping the speed of the parsing engine in PHP. I was thinking of using a DTD or Schema style but I would really like to hear any input.

Original source

Related problems