Get Smarty

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:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

Escaping Smarty Parsing

En algunas ocaciones es deseable o hasta necesario que Smarty tenga que ingonar sections o algun otro tipo analisis de sintaxis. Un ejemplo clasico es con el codigo JavaScript o CSS incrustado en el template. El problema se origina cuando aquellos lenguajes que utilizan los caracteres { y } los cuales son también los delimitadores por default para Smarty.

Esta puede ser una simple situación separando enteramente su codigo JavaScript y CSS dentro de un archivo personal y utilizar el metodo standar del HTML para el acceso.

Es posible usar literal incluyendo el contenido del bloque {literal} .. {/literal}. Similar a usar entidades HTML, usted puede usar {ldelim},{rdelim} o {$smarty.ldelim} para mostrar los delimitadores actuales.

Esto a menudo es conveniente para cambios simples a Smarty's $left_delimiter y $right_delimiter.

Example 3.7. Ejemplo cambiando delimitadores


<?php

$smarty = new Smarty;
$smarty->left_delimiter = '<!--{';
$smarty->right_delimiter = '}-->';
$smarty->assign('foo', 'bar');
$smarty->display('example.tpl');

?>

  

Donde example.tpl es:


<script language="javascript">
var foo = <!--{$foo}-->;
function dosomething() {
    alert("foo is " + foo);
}
dosomething();
</script>

  

Ver También escape modifier

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 15 plus 18? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
Cheap Hosting @HostsVault
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com