Re: Javascript and CSS

Warren Smith <wsmith-o43ciZe/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
Josh,

That will work if you do <script petal:content="structure /javascript" />.
The structure tag tells TAL to not parse out html entities (<>, etc)

However, petal will give you some problems if you do something like this:

<script>
    if(a < b) {
       window.alert("HI!");
    }
</script>

Petal has some intelligence built in so you can do:

<script>
   
    // <!--

    if(a < b) {
       window.alert("HI");
    }

    // -->
</script>

However, if you want to interpolate variables into js, you will have to 
do something like this:

<script>
    var a = "${a}";
    var b = "${b}";

    // <!--

    if(a < b) {
       window.alert("HI");
    }

    // -->
</script>

Hope this helps,

-Warren
Josh Narins wrote:

>Going to do some dynamic javascript, where the function itself is
>dynamic, and CSS is basically the same question.
>
>The big question is basically the <!-- and --> which properly goes
>around the CSS and javascript for "older" browers.
>
>That wouldn't happen here.
>
># set the javascript using perl
>$tal->{javascript} = "function a(obj) { ... stuff ... }";
>
>#template contains
><script type="text/javascript" petal:content="/javascript" />
>
>
>
>Has anyone ever tried anything like this, with javascript, either?
>Again, no <!-- and --> will work.
>
><style type="text/css">
>  .classA { <span petal:replace="/usr/style_config/classA" /> }
>  .classB { color: blue; }
></style>
>
>Cheers,
>Josh
>  
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.