2012年9月11日 星期二

symfony template


http://symfony.com/doc/current/book/page_creation.html


  • 1
    2
    3
    4
    5
    6
     {# src/Acme/HelloBundle/Resources/views/Hello/index.html.twig #}
     {% extends '::base.html.twig' %}
    
     {% block body %}
         Hello {{ name }}!
     {% endblock %}
Let's step through the Twig template line-by-line:
  • line 2: The extends token defines a parent template. The template explicitly defines a layout file inside of which it will be placed.
  • line 4: The block token says that everything inside should be placed inside a block called body. As you'll see, it's the responsibility of the parent template (base.html.twig) to ultimately render the block called body.
The parent template, ::base.html.twig, is missing both the BundleName and ControllerName portions of its name (hence the double colon (::) at the beginning). This means that the template lives outside of the bundles and in the app directory

沒有留言:

張貼留言