Nome Attributo | Tipo | Obbligatorio | Default | Descrizione |
---|---|---|---|---|
var | misto | sì | nessuno | variabile (o stringa) da valorizzare |
assign | stringa | no | nessuno | la variabile cui verrà assegnato l'output |
eval si usa per valorizzare una variabile come se fosse un template. Si può usare per incorporare tag o variabili di template dentro altre variabili, oppure tag o variabili nelle variabili dei file di configurazione.
Se fornite lo speciale attributo "assign" l'output della funzione eval sarà assegnato a questa variabile invece di essere stampato in output.
Nota tecnica
La variabili valorizzate con eval sono trattate allo stesso modo dei template. Seguono le stesse regole di escape e di sicurezza, come se fossero template
Nota tecnica
Le variabili valorizzate con eval vengono compilate ad ogni chiamata: la versione compilata non viene salvata! Comunque, se avete il caching abilitato, l'output verrà messo in cache con il resto del template.
Example 8.4. eval
setup.conf ---------- emphstart = <b> emphend = </b> title = Welcome to {$company}'s home page! ErrorCity = You must supply a {#emphstart#}city{#emphend#}. ErrorState = You must supply a {#emphstart#}state{#emphend#}. index.tpl --------- {config_load file="setup.conf"} {eval var=$foo} {eval var=#title#} {eval var=#ErrorCity#} {eval var=#ErrorState# assign="state_error"} {$state_error} OUTPUT: This is the contents of foo. Welcome to Foobar Pub & Grill's home page! You must supply a <b>city</b>. You must supply a <b>state</b>.