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 Penguraian Smarty

Ada kalanya diinginkan atau bahkan perlu agar Smarty mengabaikan seksi atau sebaliknya akan diuraikan. Contoh klasi adalah melengketkan kode Javascript atau CSS dalam sebuah template. Masalah muncul karena bahasa tersebut menggunakan karakter { dan } yang juga merupakan pembatas standar untuk Smarty.

Hal paling sederhana untuk menghindari situasi sekaligus adalah dengan memisahkan kode Javascript dan CSS anda ke dalam filenya sendiri dan kemudian menggunakan metode standar HTML untuk mengaksesnya.

Menyertakan konten literal dimungkinkan dengan menggunakan blok {literal}..{/literal}. Mirip dengan penggunaan entitas HTML, anda bisa memakai {ldelim},{rdelim} atau {$smarty.ldelim} untuk menampilkan pembatas saat ini.

Seringkali lebih nyaman dengan cukup mengubah $left_delimiter dan $right_delimiter Smarty.

Teladan 3-8. contoh mengubah pembatas

left_delimiter = \'\'; $smarty->assign(\'foo\', \'bar\'); $smarty->assign(\'name\', \'Albert\'); $smarty->display(\'example.tpl\'); ?>'); ?>

Di mana template adalah:

Welcome <!--{$name}--> to Smarty
<script language="javascript">
  var foo = <!--{$foo}-->;
  function dosomething() {
    alert("foo is " + foo);
  }
  dosomething();
</script>
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 5 plus 1? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
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
ASP.NET hosting @aspnethosting.co.uk