You're right, I forgot to mention that this was going to be the plan I went 
with to get around Chameleon parse-time problems.  On one hand, it kinda goes 
against the accepted pattern for doing client-side templating...everybody just 
jams stuff into the original page.

OTOH:

1) It results in the same thing.

2) It lets you keep the templating close to the jQuery plugin that might bundle 
up the larger widget you're making.

3) It can help avoid keeping both the QUnit templating in sync with the ZPT 
templating.

So, you're right that the pattern you have below is a good one.

--Paul

On Oct 12, 2010, at 2:32 PM, Chris Rossi wrote:

> I suspect you're going to want to store client side template separately from 
> the ZPT and inject it at render time.  Does this work?
> 
> In Python:
> 
>   jstemplate = "blah blah blah <% some expression %> blah blah"
>   rendered = render_template("template.pt", jstemplate=jstemplate)
> 
> In ZPT:
> 
>   blah blah
>   <div tal:replace="structure jstemplate"/>
>   blah blah
> 
> Chris
> 
> On Tue, Oct 12, 2010 at 1:40 PM, Paul Everitt <p...@agendaless.com> wrote:
> 
> Hi all.  Before this floats out of my brain, I thought I'd write it down and 
> see what people think.
> 
> In the past few months I've done a bit of client-side templating in jQuery, 
> first using John Resig's microtemplating:
> 
>  http://ejohn.org/blog/javascript-micro-templating/
> 
> ...as well as the just-announced-as-core templating:
> 
>  
> http://blog.jquery.com/2010/10/04/new-official-jquery-plugins-provide-templating-data-linking-and-globalization/
> 
> I used these in KARL which uses Chameleon 1.1.1.  All was happy.
> 
> I tried both today on a new project which uses Chameleon 1.2.13.  Chameleon 
> didn't like the syntax, which in one case looks like this:
> 
>  <% some expression %>
> 
> ....and in another:
> 
>  ${somevar}
> 
> In the first case, Chameleon refuses to parse the zpt because Expat tries to 
> interpret <% as a startTag.  In the second case...needless to say, it is 
> ironic that we have overlap in syntax.  I then tried wrapping a CDATA around 
> the block, but Chameleon happily plowed into the CDATA looking for stuff to 
> evaluate.
> 
> I was going down the path of demand-loading my templates with a second 
> request when I stumbled across an obscure point in the docs saying that 
> ${somevar} and {{= somevar}} are interchangeable for the second URL above.  
> Thus, I'm less in a pickle, but thought I'd bring it up anyway.
> 
> --Paul
> _______________________________________________
> Repoze-dev mailing list
> Repoze-dev@lists.repoze.org
> http://lists.repoze.org/listinfo/repoze-dev
> 
> _______________________________________________
> Repoze-dev mailing list
> Repoze-dev@lists.repoze.org
> http://lists.repoze.org/listinfo/repoze-dev

_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to