Attribute Name | Type | Required | Default | 描述 |
---|---|---|---|---|
file | string | Yes | n/a | The name of the template file to include |
assign | string | No | n/a | The name of the variable that the output of include will be assigned to |
[var ...] | [var type] | No | n/a | variable to pass local to template |
屬性 | 類型 | 是否必須 | 缺省值 | 描述 |
---|---|---|---|---|
file | string | Yes | n/a | 待包含的模板文件名 |
assign | string | No | n/a | 該屬性指定一個(gè)變量保存待包含模板的輸出 |
[var ...] | [var type] | No | n/a | 傳遞給待包含模板的本地參數(shù),只在待包含模板中有效 |
Include 標(biāo)簽用于在當(dāng)前模板中包含其它模板. 當(dāng)前模板中的變量在被包含的模板中可用. 必須指定 file 屬性,該屬性指明模板資源的位置.
如果設(shè)置了 assign 屬性,該屬性對(duì)應(yīng)的變量名用于保存待包含模板的輸出,這樣待包含模板的輸出就不會(huì)直接顯示了。
Example 7-6. function include
|
可以在屬性中傳遞參數(shù)給待包含模板. 傳遞給待包含模板的參數(shù)只在待包含模板中可見(jiàn). 如果傳遞的參數(shù)在待包含模板中有同名變量,那么該變量被傳遞的參數(shù)替代.
Example 7-7. function include passing variables
|
包含 $template_dir 文件夾之外的模板請(qǐng)使用 模板資源 說(shuō)明的格式.
Example 7-8. function include template resource examples
|