Chapter IV Jinja2 template

Template Description:
In the previous section, the view function simply returns the text directly, but most of the pages in the actual production environment is complicated HTML code with style and logic, which allows the browser to render a very nice page. Currently on the market there are a lot of template system, easy to use is one of the most well-known] inja2 and Mako,
features two different templates:
1.Jinja2:] Inja is the meaning of the Japanese temple, and the temple is a temple and English English template template similar pronunciation. Jinja2 is the default template engine imitation of a Django template, developed by the author F1ask. It's fast, widely used, and offers an optional sandbox template to ensure secure execution environment, it has the following advantages:

  • Front-end and back-end developers let developers work separate.
  • Reduce F1ask project code coupling, logic on the page template, the business logic in the view function, the page logic and business logic decoupling conducive to the maintenance of the code.
  • It provides control statements, inheritance and other advanced features, reduce the complexity of development.

2.Marko: Marko is another well-known template. He draws a lot of grammar and APl from Django, Jinja2 and other templates, he has the following advantages:

  • Performance and] inja2 close
  • There are success stories there are, in the use of large sites, Reddit and watercress are in use.
  • There are well-known web framework support. Pylons and Pyramid of these two web framework built-in templates that Mako
  • Support almost written in native code template Python syntax, Python engineer for more friendly, high development efficiency.
  • It comes complete caching system. Of course, provides a very good excuse to expand, it is easy to switch to a different caching system.

Guess you like

Origin www.cnblogs.com/wqbin/p/11828643.html