Let me make a note: extendThe main purpose of inherited templates is for sub-templates to reference its structure and supplement the block content in it.
import引用的模板主要为了在子模板中引用它的变量,宏函数等。类似import osThis way, you can also define macro functions with the same name. bootstrap/wtf.html source code
The subject’s question link on stackoveflow: what are the differences between import and extends in Flask?
extends are generally used in template calls. For example, the content in your base.html is the main frame of the web page, with buttons, navigation, etc. at the top. And in other pages, such as xxxxx.html, the basic frame is the same. , and you only need to modify the content of the page, then you don’t have to rewrite the code of the main frame in xxxxx.html every time, and you can “copy” the main frame by inheriting from base.html
And import is generally used to reference modules or functions For example, the import os that we usually use most is to introduce the standard os module
Let me make a note:
extend
The main purpose of inherited templates is for sub-templates to reference its structure and supplement the block content in it.import
引用的模板主要为了在子模板中引用它的变量,宏函数等。类似import os
This way, you can also define macro functions with the same name. bootstrap/wtf.html source codeThe subject’s question link on stackoveflow: what are the differences between import and extends in Flask?
extends means inheritance, import means reference. Inheritance can change the original content, but reference cannot
extends are generally used in template calls. For example, the content in your base.html is the main frame of the web page, with buttons, navigation, etc. at the top.
And in other pages, such as xxxxx.html, the basic frame is the same. , and you only need to modify the content of the page, then you don’t have to rewrite the code of the main frame in xxxxx.html every time, and you can “copy” the main frame by inheriting from base.html
And import is generally used to reference modules or functions
For example, the import os that we usually use most
is to introduce the standard os module