[Petal] Javascript and CSS
    Warren Smith 
    wsmith at hbslabs.com
       
    Tue Oct 11 15:31:42 BST 2005
    
    
  
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
>  
>
    
    
More information about the Petal
mailing list