Differences between Django templates and PHP templates and front-end templates

Source: Internet
Author: User
Tags php template codeigniter drupal
Before learning Django templates, I thought that, like many php template engines, it was implemented by caching file output and executing python code in the template. After reading the template, I found that it is similar to the front-end template and uses regular expressions. In order to better understand the design philosophy, I also referred to the templates in tornato, drupal, codeigniter, aceTemplate, and underscore.

Before learning Django templates, I thought that, like many php template engines, it was implemented by caching file output and executing python code in the template. After reading the template, I found that it is similar to the front-end template and uses regular expressions. In order to better understand the design philosophy, I also referred to the templates in tornato, drupal, codeigniter, aceTemplate, and underscore.

Before learning Django templates, I thought that, like many php template engines, it was implemented by caching file output and executing python code in the template. After reading the template, I found that it is similar to the front-end template and uses regular expressions.

To better understand the design philosophy, I also referred to the template design in tornato, drupal, codeigniter, aceTemplate, and underscore.

Django template features

There is an important assumption when designing a Django template: "you do not understand python when writing a template ". Therefore, you only need to write the basic logic structure (Judgment, loop, output variable, etc.) to tell him. It also avoids programmers from writing business logic into the template. When parsing a template, It is very similar to the front-end template. It also uses regular expressions to extract all the code parts and then parses them sequentially (the scope is constructed according to the actual situation during parsing) into html.

The template implementation in php is relatively simple, mainly through buffering the output stream. The template uses the normal php code. This is mainly because php files directly output text not included in the php tag. Therefore, php templates can directly execute php code.

Here we can see that there are two completely different design ideas. Django proactively sets limits on Template users and wants to implement a small template language on its own. Tornato, php templates, and front-end templates allow developers to minimize learning costs and gain great freedom. However, the main reason why front-end templates give developers great freedom is that html and front-end logic are almost all written by individuals.

2. Supports template nesting

3. support template inheritance

Summary

I think the following are interesting:

1. No matter which template is implemented, it does not actually have a dime relationship with html.

2. The speed must be the fastest direct cache output stream like php. After all, the template compilation step is saved. If the python statement generated by tornato is encapsulated as a function, it can be cached.

3. The implementation of the Django template may be related to the design philosophy of the entire framework. I have not read it yet, so I will not comment on it. But at least I have explained why in the book.

At the beginning, I started to learn python and Django. If something is wrong, I would like to thank you for your correction.

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.