escape

Posición del ParametroTipoRequeridoPosibles ValoresDefaultDescription
1stringNohtml,htmlall,url,quotes,hex,hexentity,javascripthtmlEste es el formato de escape a utilizar.

Este es usado para escapar html, url, comillas simples para escapar una variable que no este escapada, escapar hex, hexentity o javascript. Por default, la variable html es escapada.

Ejemplo 5-10. escape

<?php

$smarty
->assign('articleTitle',
                
"'Stiff Opposition Expected to Casketless Funeral Plan'"
                
);

?>

Donde el template es:

{$articleTitle}
{$articleTitle|escape}
{$articleTitle|escape:"html"}    {* escapes  & " ' < > *}
{$articleTitle|escape:"htmlall"} {* escapes ALL html entities *}
{$articleTitle|escape:"url"}
{$articleTitle|escape:"quotes"}
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>

esta es la salida:

'Stiff Opposition Expected to Casketless Funeral Plan'
&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27
\'Stiff Opposition Expected to Casketless Funeral Plan\'
<a href="mailto:%62%6f%..snip..%65%74">&#x62;&#x6f;&#x62..snip..&#x65;&#x74;</a>

Ver también Escaping Smarty Parsing y Obfuscating E-mail Addresses.