escape
escape dipakai untuk mengkodekan atau mengubah variabel ke contohnya html,
url, tanda kutip tunggal,
heksa, heksentitas,
javascript dan mail.
Standarnya html.
Teladan 5-10. escape
assign(\'articleTitle\',
"\'Stiff Opposition Expected to Casketless Funeral Plan\'"
);
$smarty->assign(\'EmailAddress\',\'smarty@example.com\');
?>');
?> |
Ini adalah contoh baris template escape diikuti oleh output
{$articleTitle}
'Stiff Opposition Expected to Casketless Funeral Plan'
{$articleTitle|escape}
'Stiff Opposition Expected to Casketless Funeral Plan'
{$articleTitle|escape:'html'} {* escapes & " ' < > *}
'Stiff Opposition Expected to Casketless Funeral Plan'
{$articleTitle|escape:'htmlall'} {* escapes SEMUA entri html *}
'Stiff Opposition Expected to Casketless Funeral Plan'
<a href="?title={$articleTitle|escape:'url'}">click here</a>
<a href="?title=%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27">click here</a>
{$articleTitle|escape:'quotes'}
\'Stiff Opposition Expected to Casketless Funeral Plan\'
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
{$EmailAddress|escape:'mail'} {* this converts to email to text *}
<a href="mailto:%62%6f%..snip..%65%74">bob..snip..et</a>
{'mail@example.com'|escape:'mail'}
smarty [AT] example [DOT] com |
|
Teladan 5-11. Contoh lain Fungsi PHP dapat dipakai sebagai pengubah,
$security yang mengijinkan.
{* parameter "rewind" meregistrasi lokasi sekarang *}
<a href="{$SCRIPT_NAME}?page=foo&rewind={$smarty.server.REQUEST_URI|urlencode}">click here</a> |
This snippet is useful for emails, but see also
{mailto} {* alamat email dipotong *}
<a href="mailto:{$EmailAddress|escape:'hex'}">{$EmailAddress|escape:'mail'}</a> |
|
Lihat juga
escaping penguraian smarty,
{mailto}
dan halaman
mengaburkan alamat email.