Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 8377d4bb25a3992aad680df2952f4b71 > files > 65

php-smarty-doc-2.6.26-1mdv2010.0.noarch.rpm

<HTML
><HEAD
><TITLE
>Escaping Smarty Parsing</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Smarty Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Basic Syntax"
HREF="language.basic.syntax.html"><LINK
REL="PREVIOUS"
TITLE="Math"
HREF="language.math.html"><LINK
REL="NEXT"
TITLE="Variables"
HREF="language.variables.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Smarty Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="language.math.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 3. Basic Syntax</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="language.variables.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="language.escaping"
></A
>Escaping Smarty Parsing</H1
><P
>&#13;  It is sometimes desirable or even necessary to have Smarty ignore sections it
  would otherwise parse. A classic example is embedding Javascript or CSS code in
  a template. The problem arises as those languages use the { and } characters
  which are also the default
  <A
HREF="language.function.ldelim.html"
>delimiters</A
> for Smarty.
 </P
><P
>&#13;  The simplest thing is to avoid the situation altogether by separating your Javascript
  and CSS code into their own files and then using standard HTML methods to access them.
 </P
><P
>&#13;  Including literal content is possible using <A
HREF="language.function.literal.html"
>&#13;  <TT
CLASS="varname"
>{literal}..{/literal}</TT
></A
> blocks.
  Similar to HTML entity usage, you can use <A
HREF="language.function.ldelim.html"
><TT
CLASS="varname"
>{ldelim}</TT
></A
>,<A
HREF="language.function.ldelim.html"
><TT
CLASS="varname"
>{rdelim}</TT
></A
> or <A
HREF="language.variables.smarty.html#language.variables.smarty.ldelim"
>&#13;  <TT
CLASS="varname"
>{$smarty.ldelim}</TT
></A
> to display the current delimiters.
 </P
><P
>&#13;  It is often convenient to simply change Smarty's <A
HREF="variable.left.delimiter.html"
>&#13;  <TT
CLASS="parameter"
><I
>$left_delimiter</I
></TT
></A
> and
  <A
HREF="variable.right.delimiter.html"
>&#13;  <TT
CLASS="parameter"
><I
>$right_delimiter</I
></TT
></A
>.
 </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN347"
></A
><P
><B
>Example 3-7. changing delimiters example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">left_delimiter&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'&lt;!--{'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">right_delimiter&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'}--&gt;'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">assign</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'bar'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">assign</span><span style="color: #007700">(</span><span style="color: #DD0000">'name'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Albert'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$smarty</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">(</span><span style="color: #DD0000">'example.tpl'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></TD
></TR
></TABLE
><P
>&#13;   Where the template is:
  </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>Welcome &#60;!--{$name}--&#62; to Smarty
&#60;script language="javascript"&#62;
  var foo = &#60;!--{$foo}--&#62;;
  function dosomething() {
    alert("foo is " + foo);
  }
  dosomething();
&#60;/script&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="language.math.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="language.variables.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Math</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="language.basic.syntax.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Variables</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>