- Flask By Example
- Gareth Dwyer
- 236字
- 2021-07-09 20:06:54
Chapter 3. Using Templates in Our Headlines Project
In the last chapter, we saw one way of combining static HTML with dynamic content for creating a web page. But it's messy, and we don't want to hack away at Python strings for building our web pages. Mixing HTML and Python is not ideal for a few reasons: for one, it means if we ever want to change static text, such as that which appears in our headings, we have to edit our Python files, which also involves reloading these files into Apache. If we hire frontend developers to work on HTML, we run the risk of them breaking the unfamiliar Python code by mistake, and it's far more difficult to structure any other frontend code such as JavaScript and CSS correctly. Ideally, we should aim for complete segregation between the frontend and backend components. We can achieve this to a large extent using Jinja, but as with most aspects of life, some compromise will be necessary.
By the end of this chapter, we'll have extended our application to display more than a single headline for the chosen publication. We'll display several articles for each publication, each one having a link to the original article, and our logic and view components will largely be separated. In this chapter, we'll cover the following topics:
- Introducing Jinja
- Basic use of Jinja templates
- Advanced use of Jinja templates
- 案例式C語言程序設計
- Delphi程序設計基礎:教程、實驗、習題
- Python數據分析入門與實戰
- Xcode 7 Essentials(Second Edition)
- Java開發入行真功夫
- C語言程序設計同步訓練與上機指導(第三版)
- Salesforce Reporting and Dashboards
- Lighttpd源碼分析
- Mastering Unity 2D Game Development(Second Edition)
- Android群英傳
- Node.js開發指南
- SSH框架企業級應用實戰
- Mastering Leap Motion
- Java設計模式深入研究
- Learning D3.js 5 Mapping(Second Edition)