>
> As for jQuery and Prototype I use the '\$'.
>

With so much of jQuery's functionality based around the $() it became a pain
to escape every `$`.

I see what you're going for. Have you considered using JSON? I may be wrong
but if you're looking to solely create JavaScript objects, why not pass the
dirty work on to an efficient module?

# angelo.html

$def with (json)
<script type="text/javascript">eval($json)</script>

# code.py

class angelo:
    def GET(self):
        import cjson
        foo = {'x':1, 'y':2, 'v':range(0,10)}
        return web.output(render.angelo(cjson.encode(foo)))

That of course is not identical code. Are you sure you want multiple `v`
variables set (v1=1, v2=2, v3=3)? Either way, this both cleans up your HTML
template as well as prevents having to pass python objects to be parsed
inefficiently from within templator. What do you think?

As for the comments, I wonder if it would be worth the trouble. Maybe
provide an optional `_strip=False` to the render call which strips both HTML
& JS commentary. However, doing this by default would slow things down and
remove potentially useful (to the end client) comments.

On 8/26/07, Tzury <[EMAIL PROTECTED]> wrote:
>
>
> >I was experiencing problems with inline scripts in my HTML while using
> the
> >$() functionality of Prototype and jQuery. That is, until I removed them
> as
>
> As for jQuery and Prototype I use the '\$'.
>
> > I've always considered templates to be HTML files with inline Python.
> Thus,
> > you should try to keep the contents to only HTML (or XML/XHTML). Keeping
> the
> > JavaScript in an external file is the preferred method when possible
> just as
> > you should try to do with CSS -- separation of content, presentation,
> and
> > `enlivenment` or so I've heard it called.
>
> The idea of separation is something all should follow when possible,
> no doubt. Yet, sometimes I dynamically generate JS objects which
> contain the data I use within the page.
> For example:
>
> #TEMPLATE (angelo.html)
>
> $def with (foo, bar)
> <script type="text/javascript">
>     var x = $foo["x"];
>     var y = $foo["y"];
>     $for b in bar:
>         var v$b = $b
>
> </script>
>
>
> #code.py
>
> class angelo
>     def GET(self):
>         foo = {"x":1, "y":2}
>         bar = range(0,10)
>         print render.angelo(foo, bar)
>
> I don't see how it is can be done otherwise except with ajax which I
> don't feel like using for page initiation in order to save extra
> request/response time waste.
>
>
>
> >
>


-- 
Angelo Gladding
[EMAIL PROTECTED]
http://angelogladding.com
(626) 755 - 1417

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to