Re: [SMARTY] Smarty and possibility to parse Javascript-Files?
| From: | Matthias Mohr | Date: | Fri, 07 Mar 2003 01:49:44 +0000 |
| Subject: | Re: [SMARTY] Smarty and possibility to parse Javascript-Files? | ||
| References: | 1 2 3 4 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-8467@lists.php.net to get a copy of this message | ||
> Matthias,
>
> Could you just do:
> ----------------------------------------------------------------------------
> -
> <script language="javascript" type="text/javascript"
> src="js/CookieMgmt.php"> <-note the extension change
> </script>
> ----------------------------------------------------------------------------
> -
>
> And have another Smarty aware script there?
You mean to write out the javascript-code via PHP?
I don't think this would work.
Or are the browsers intelligent enought to handle your suggestion and really load
the js/CookieMgmt.php as PHP-code (and not as javascript)?
> ----- Original Message -----
> From: "Matthias Mohr" <MMohr@sysdesign-edv.de>
> Cc: <smarty-general@lists.php.net>
> Sent: Thursday, March 06, 2003 5:52 AM
> Subject: [SMARTY] Smarty and possibility to parse Javascript-Files?
>
>
> > I sometimes use Smarty-variables inside my javacript code like this:
> > (of course I changed the Smarty-delimiters to "<{" and "}>", so
> > that it
> will
> > work inside javascript-code)
> > --------------------------------------------------------------------------
> ---
> > <script language="javascript" type="text/javascript">
> > <!--
> > function storevalue( Value ) {
> > var CookieName = "<{$cookiename}>";
> >
> > set_cookie( CookieName, value );
> > }
> > //-->
> > </script>
> > --------------------------------------------------------------------------
> ---
> >
> > in the above (incomplete) example, I use the smarty-variable "cookiename"
> > as the name of the cookie to which something has to be stored.
> > So I can easily change my cookiename through an PHP-configuration file.
> > The templates and also the javascript-code works perfect without knowledge
> > of the name.
> >
> > But when I use more complex javascript-code, I would like to have it in
> > separate Javascript-Files, like that:
> > --------------------------------------------------------------------------
> ---
> > <script language="javascript" type="text/javascript"
> src="js/CookieMgmt.js">
> > </script>
> > --------------------------------------------------------------------------
> ---
> >
> > So if I put the above javascript-code in the CookieMgmt.js I have (of
> course)
> > to remove the smarty-tags.
> > So the javascript-code has to have the knowledge of the
> cookiename-variable
> > or it is incomplete and needs this variable to be set "somewhere else".
> > So either I must hold the information twice (once in PHP and another time
> in
> > the javascript-file)
> > or I must live with incomplete javascript-code and write it like follows:
> > --------------------------------------------------------------------------
> ---
> > <script language="javascript" type="text/javascript">
> > <!--
> > var CookieName = "<{$cookiename}>";
> > //-->
> > </script>
> > <script language="javascript" type="text/javascript"
> src="js/CookieMgmt.js">
> > </script>
> > --------------------------------------------------------------------------
> ---
> >
> > To come to an conclusion:
> > I think it would be a nice feature, if smarty would have the possibility
> to parse
> > also included javascript-files
> >
> > what do you think?
> >
> > with regards,
> > Matthias
> >
> >
> >
> > --
> > Smarty General Mailing List (http://smarty.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>