{literal} <script language="text/javascript"> ... </script> {/literal}
참조
http://www.smarty.net/manual/en/language.function.literal.php{literal}
{literal} tags allow a block of data to be taken literally. This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter syntax. Anything within {literal}{/literal} tags is not interpreted, but displayed as-is. If you need template tags embedded in a {literal} block, consider using {ldelim}{rdelim} to escape the individual delimiters instead.
Example 7-25. {literal} tags
{literal} <script type="text/javascript"> <!-- function isblank(field) { if (field.value == '') { return false; } else { document.loginform.submit(); return true; } } // --> </script> {/literal}
Example 7-26. Javascript function example
<script language="JavaScript" type="text/javascript"> {literal} function myJsFunction(name, ip){ alert("The server name\n" + name + "\n" + ip); } {/literal} </script> <a href="javascript:myJsFunction('{$smarty.server.SERVER_NAME}','{$smarty.server.SERVER_ADDR}')">Click here for the Server Info</a>
Example 7-27. Some css style in a template
{* included this style .. as an experiment *} <style type="text/css"> {literal} /* this is an intersting idea for this section */ .madIdea{ border: 3px outset #ffffff; margin: 2 3 4 5px; background-color: #001122; } {/literal} </style> <div class="madIdea">With smarty you can embed CSS in the template</div>See also {ldelim} {rdelim} and the escaping Smarty parsing page.
{ldelim},{rdelim}
{ldelim} and {rdelim} are used for escaping template delimiters, by default { and }. You can also use {literal}{/literal} to escape blocks of text eg Javascript or CSS. See also the complimentary {$smarty.ldelim}.
Example 7-23. {ldelim}, {rdelim}
{* this will print literal delimiters out of the template *} {ldelim}funcname{rdelim} is how functions look in Smarty!The above example will output:
{funcname} is how functions look in Smarty!Another example with some Javascript
<script language="JavaScript"> function foo() {ldelim} ... code ... {rdelim} </script>will output
<script language="JavaScript"> function foo() { .... code ... } </script>
Example 7-24. Another Javascript example
<script language="JavaScript" type="text/javascript"> function myJsFunction(){ldelim} alert("The server name\n{$smarty.server.SERVER_NAME}\n{$smarty.server.SERVER_ADDR}"); {rdelim} </script> <a href="javascript:myJsFunction()">Click here for Server Info</a>See also {literal} and escaping Smarty parsing.
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- SVN
- Selectbox
- Eclipse
- 부모창
- centos
- 천단위
- MySQL
- 확장자
- JavaScript
- Postfix
- install
- replace
- random
- docker
- 문자열자르기
- Python
- yum
- TPL
- mariadb
- ubuntu
- 일괄변경
- i18n
- 한글 깨짐
- RabbitMQ
- TextBox
- php
- jQuery
- smarty
- Oracle
Archives
- Today
- Total
wilson's story
smarty template 에 javascript 사용하기 본문
반응형
Not processing javascript in smarty templates
Use {literal}...{/literal} tags around the javascript within your smarty template:
반응형