25 May 2014
Creating and Using Templates [第7天]
As you know, the controller is responsible for handling each request that comes into a Symfony2 application. In reality, the controller delegates most of the heavy work to other places so that code can be tested and reused. When a controller needs to generate HTML, CSS or any other content, it hands the work off to the templating engine. In this chapter, you’ll learn how to write powerful templates that can be used to return content to the user, populate email bodies, and more. You’ll learn shortcuts, clever ways to extend templates and how to reuse template code.
How to render templates is covered in the controller page of the book.
A template is simply a text file that can generate any text-based format (HTML, XML, CSV, LaTeX …). The most familiar type of template is a PHP template - a text file parsed by PHP that contains a mix of text and PHP code:
Til next time,
Xujiajun at 07:39