Interesting Wyatt. What do you mean by a JSON/JS approach? So you factor it in a way that you won't have to use templates for doing string replacements? Can you give a small example?
I already have the static files jquery etc. as separate static resources. However, I have these functions that however need to be altered a bit in the js code itself. Also, another disadvantage is that inline code in script tags does not get run when it is loaded via a jquery AJAX. The opposite (as in a separate js file) however is true. And I wonder if it is better to be able to serve these small snippets as separate js files rather than inline, so that they get loaded even if downloaded via AJAX. I guess then I will have to assign a special view/route to these dynamic snippets, and render via a template. Ahmed On Dec 19, 9:32 am, Wyatt Baldwin <[email protected]> wrote: > On Sunday, December 18, 2011 9:39:28 AM UTC-8, Chris Rossi wrote: > > > On Sun, Dec 18, 2011 hat 7:55 AM, Ahmed <[email protected]> wrote: > > > I wonder what is the best practice for my case? And if using a > > > template renderer is the best solution, how is that best made? For > > > example is the Chameleon text template suitable for this job? > > > That's what I would use. I'm usually able to factor my js in such a > > way, though, that my js files can be served statically and only depend > > a few lines of dynamic data injected into the html page in a <script> > > tag. > > Similarly, I create a single JSON config object in a helper function and > inject it into the template; it gets passed to a main JavaScript function > (defined in a separate script file), which sort-of reflects how a Pyramid > app is initialized. > > For a while, I did some dynamic JS setup using Mako, but it was a bit > messy, and I prefer the straight JSON/JS approach. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en.
