Re: Re: literal and javascript
messju mohr <[email protected]>
| Newsgroups | gmane.comp.php.smarty.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Mar 17, 2004 at 12:51:15PM +0000, pete M wrote:
> for the application I'm creating - the javascript is in the template
then don't use { and } as delimiters.
> and a lot of interaction with form elements, would be difficult to code in
> .js file !?
not necessarily. put the stuff in functions in the .js-file and pass
"this" from the on-*-handlers in the html as a parameter to these
functions.
if you really want the syntax you suggested below, write a simple
prefilter that replaces the "`*`" (or whatever) inside literal-tags by
"{/literal}*{literal}".
while you're at it, you could even go a little further and look for
{javascript}...{/javascript} in your template, replace it with
{literal}...{/literal} and only do the backticks-replacement in the
{javascript}-blocks.
calling the block {literal} and doing *anything* modifying it's
contents is really misleading, IMHO.
greetings
messju
> pete
>
> Ruben Vermeersch wrote:
> >Making it impossible to output any code that contains backticks in the
> >literal section (php code, shell scripts, ...)
> >
> >My meaning about javascript: use external scripts, they also save you
> >bandwidth, and make your whole site more efficient.
> >
> >Ruben
> >
> >On Wed, 2004-03-17 at 13:24, pete M wrote:
> >
> >>I think some have missed my point.
> >>The idea is to use backticks as delimiters within javascript code
> >>enclosed between {literal} tags
> >>
> >>eg------
> >>
> >>{literal}
> >>function foo{
> >> bar = `$some_smarty_variable` + 1;
> >> if(bar > 0) {
> >> bar2 = bar * `$some_other_smarty_variable`;
> >> }
> >>{
> >>{/literal}
> >>
> >>instead of -----
> >>
> >>
> >>{literal}
> >>function foo{
> >> bar = {/literal}$some_smarty_variable{literal} + 1;
> >> if(bar > 0) {
> >> bar2 = bar * {/literal}$some_other_smarty_variable{literal};
> >> }
> >>{
> >>
> >>{/literal}
> >>
> >>just an idea to make the coding easier to code and read
> >>
> >>pete
> >>
> >>
> >>
> >>Messju Mohr wrote:
> >>
> >>>On Tue, Mar 16, 2004 at 06:37:00PM +0300, Konstantin A. Pelepelin wrote:
> >>>
> >>>
> >>>>>could smarty somehow have variables within the {literal} tags eg in
> >>>>>Backticks or some "non used" javascript code ?
> >>>>
> >>>>Please don't!
> >>>
> >>>
> >>>Yes, please don't!
> >>>
> >>>Literal should do what it's name says: pass the contents through
> >>>*literally*.
> >>>
> >>>
> >>>
> >>>>JavaScript is the reason why I use alternate Smarty delimiters {{ }}.
> >>>>Unfortunately, people used to use default { }.
> >>>>
> >>>>Konstantin A. Pelepelin
> >>>>DTF.RU
>
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php