Get Smarty

Donate

Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Advertisement

eval

Nome Attributo Tipo Obbligatorio Default Descrizione
var misto 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>.


Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors