Django Book 翻译
菜单>:
TOC
返回
原文:
Now that weve covered the template-loading mechanism, we can introduce a built-in template tag that takes advantage of it: ``{% include %}`` . This tag allows you to include the contents of another template. The argument to the tag should be the name of the template to include, and the template name can be either a variable or a hard-coded (quoted) string, in either single or double quotes. Anytime you have the same code in multiple templates, consider using an ``{% include %}`` to remove the duplication.
翻译:
在讲解了模板加载机制之后,我们再介绍一个利用该机制的内建模板标签: ``{% include %}`` 。该标签允许在(模板中)包含其它的模板的内容。标签的参数是所要包含的模板名称,可以是一个变量,也可以是用单/双引号硬编码的字符串。每当在多个模板中出现相同的代码时,就应该考虑是否要使用 ``{% include %}`` 来减少重复。
备注:
译者: