From: Steve <unetright.thebas...@xoxy.net>
Date: Sat, 6 Jun 2009 06:01:04 -0700 (PDT)
Local: Sat, Jun 6 2009 9:01 am
Subject: Re: pyTenjin Feature Requests
I wanted:
>> <body>
You suggested:
>> <div> >> <p> >> <?py if boolean: ?> >> some conditional text >> <?py #endif ?> >> </p> >> </div> >> </body> > What I can do is to extend Template class to add dummy 'if' statement.
Thank you! That's great. The code you use to support this is not
> class MyTemplate(tenjin.Template): > def convert(self, input, filename=None):
> def add_stmt(self, buf, code):
straight-forward to me because I am unfamiliar with the inner workings of the template class. In your example you used <?py for item ... ?> indentation. Can you tell me if it will also work with the indentation outside the py tag style? Like this: <html>
The reason I would like to make sure this will still work relates to
>> Another problem I have is that my django templates get pre-processed
I think this will not be too hard to fix on my end. I can write my
>> with an html compressor which strips out redundant whitespace. Since > '30% reduction' is very impressive. > Hmm, it is difficult for Tenjin to strip spaces automatically and > correctly. > I don't have a good solution for this issue, but I'll try to think it. own simple compressor which will combine all whitespace except when it matches "^\w*<?py". Since I have rewritten most of my inline conditionals to use helper functions, I have relatively few <?py ?> statements so this scheme would get me 95% of the way to my original file sizes. [From your reply to my email]
>> to list them all in the arguments line. What I would really like is
Thank you again! Because of the strict indentation requirements of <?
>> simply every ${var} and #{var} to automatically translate to >> _context.get('var', None) instead of raising exceptions when var is >> not passed in through the context. > How to create your own Template class and convert "@var" > into "_context.get('var', None)" automatically? > def _expand(code): > """expand '@var' into '_context.get("var", None)'""" > return re.sub(r"@(\w+)", r"_context.get('\1', None)", code) > class MyTemplate(tenjin.Template):
> def add_stmt(self, buf, code):
> def add_expr(self, buf, code, flag_escape=None):
py ?> statements I have tried to avoid them for conditionals whenever possible. So I have a lot of constructs like: #{(_context.get(conditional, False) and 'true text') or 'false text'} These "conditionals" are like optional flags to the template. They
For me at least, that small reduction brings it down to the point
>> Preliminary benchmarks show pyTenjin to compare extremely
I have finished my initial port of my templates to pyTenjin. I am
>> favorably to the GAE built-in django templates. I have several >> inline conditionals to try to translate to Tenjin helper >> functions. After that I will be sure to post some concrete >> performance numbers. happy to report that running on my GAE dev environment requests which result in uncached template creation are running 10-15% quicker. Requests which result use in memory (not memcache) cached templates are running around 30% quicker than their in memory cached django counterparts. It is not easily possible to measure the performance of the gaememcached scenario on the single-threaded dev server. Since I am reluctant to turn on profiling of the deployed application I cannot judge that scenarios performance with respect to uncached django performance (uncached since django does not memcache). I would also like to point out that the 10-15% / 30% improvements are
All in all I am quite pleased with how pyTenjin is performing. With
Thank you very much for all your help in trying to make this work for
Regards,
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||