Symfony2 twig Template engine

Source: Internet
Author: User
1. Basic grammar

Says something:{{}}

Does something:{%%}

Comment something:{# #}

{% extends "Appwebbundle::layout.html.twig"%} inherit template

2. Core concept:

Managing relationships between pages using the inheritance relationships of classes

If you want to access a resource file in a bundle, you need to copy the file to the/web directory, or the Linux/mac soft connection is mapped to the/web directory

Windows: >php app/console assets:install Web

Linux: >php app/console assets:install Web--symlink--relative

3. js CSS File Management

(1) Use a Css/js file directly: {{asset (' Xxx.js ')}}

(2) Register/define resource: {% javascripts%} {% stylesheets%}

# All JS files in the ' appwebbundle/resources/public/js/' directory will be output sequentially
{% block my_js%} {% javascripts ' @AppWebBundle/resources/public/js/* '%} {% endjavascripts%} { % endblock%}

And in the APP/CONFIG/CONFIG.YML configuration:

Assetic:    bundles:        [Appwebbundle]

(3) Common policies for sharing css/js files between pages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.