[PHPTAL] Generate string in Javascript with TAL

tarjei tarjei at nu.no
Mon Apr 16 08:57:16 CEST 2007


Michal Ludvig wrote:
> Hi all,
>
> I need to generate a string into a simple JavaScript code.
>
> The goal is like this:
>
> <script language="javascript" type="text/javascript">
> google_kw = "keyword1, keyword2";
> </script>
>
> My code is:
>
> <script language="javascript" type="text/javascript">
> google_kw = "<span tal:replace="structure page/meta_keywords" />";
> </script>
>
> Unfortunately the output of this code has the quotes (") replaced by 
> entities (&quot;):
>
> <script language="javascript" type="text/javascript">
> google_kw = &quot;keyword1, keyword2&quot;;
> </script>
>
> How can I get rid of this replacing? Or is there another way to 
> achieve my goal other than generating the whole JS code in PHP and 
> outputting it with tal:content?
Hi, use CDATA and the ${} construct:
 <script type="text/javascript">
                    //<![CDATA[
                    _uacct='${googleAnalyticsCode}';
                    urchinTracker();
                    //]]>
         </script>
Tarjei
>
> Thanks
>
> Michal
>
>
>
> _______________________________________________
> PHPTAL mailing list
> PHPTAL at lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal




More information about the PHPTAL mailing list