| Attribute Name | Type | Required | Default | Description |
|---|---|---|---|---|
| var | mixed | Yes | n/a | variable (or string) to evaluate |
| assign | string | No | n/a | the template variable the output will be assigned to |
eval is used to evaluate a variable as a template. This can be used for things like embedding template tags/variables into variables or tags/variables into config file variables.
eval 會將變數視為樣版,使用的情況類似在變數中嵌入樣版標籤/變數等, 或是在組態檔案變數中嵌入標籤/變數。
If you supply the special "assign" attribute, the output of the eval function will be assigned to this template variable instead of being output to the template.
如果你有使用 "assign" 屬性,則 eval 函式的輸出會被指定給某個樣版變數 而不會直接輸出至樣版。
Technical Note: Evaluated variables are treated the same as templates. They follow the same escapement and security features just as if they were templates.
技術提醒: 使用 eval 的變數會被視為樣版,也有使用脫序與安全的特性,如同樣版一般。
Technical Note: Evaluated variables are compiled on every invocation, the compiled versions are not saved! However if you have caching enabled, the output will be cached with the rest of the template.
技術提醒: 被 eval 包圍起來的變數只有在被引用時才會被編譯,編譯後的結果將不會被儲存 起來!不過,如果你有設定快取的話,輸出的結果將會連同樣版的其他部分一起被快取住。