Skip to content
Myr

[svn] some small jinja changes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent a690146 · Browse files · 5 files+16 added−26 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+16 added−26 removed

  • tests:+10 added−9 removed
  • other:+6 added−17 removed

5 files+16 added−26 removed

modified:jinja/datastructure.py+1 added-2 removed
174 unmodified lines
175 result[key] = value176 return result177178 def __getitem__(self, name):179 # don't give access to jinja internal variables179 if name.startswith('::'):180 return Undefined181 # because the stack is usually quite small we better use [::-1]182 # which is faster than reversed() somehow.183 for d in self._stack[::-1]:184 if name in d:185 rv = d[name]187 if isinstance(rv, Deferred):186 if rv.__class__ is Deferred:187 rv = rv(self, name)188 # never touch the globals!189 if d is self.globals:190 self.initial[name] = rv
211 unmodified lines
modified:jinja/environment.py-1 removed
205 unmodified lines
206 """207 if value is Undefined or value is None:208 return u''209 val = self.to_unicode(value)210 # apply default filters210 if self.default_filters:211 val = self.apply_filters(val, ctx, self.default_filters)212 return val
modified:jinja/nodes.py+2 added-3 removed
7 unmodified lines
8 :copyright: 2007 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10"""11from compiler import ast12from copy import copy131415def inc_lineno(offset, tree):16 """
259 unmodified lines
276 def clone(self):277 """278 Create an independent clone of this node.279 """279 rv = Block(None, None, None)280 rv.__dict__.update(self.__dict__)281 return rv280 return copy(self)281282 def get_items(self):283 return [self.name, self.body]284
65 unmodified lines
modified:jinja/utils.py+3 added-11 removed
149 unmodified lines
150 return range(start, stop, step)151152153# python2.4 and lower has a bug regarding joining of broken generators154if sys.hexversion < (2, 5):155 def capture_generator(gen):156 """157 Concatenate the generator output.158 """159 return u''.join(tuple(gen))154if sys.version_info < (2, 5):155 capture_generator = lambda gen: u''.join(tuple(gen))156157# this should be faster and used in python2.5 and higher158else:163 def capture_generator(gen):164 """165 Concatenate the generator output166 """167 return u''.join(gen)159 capture_generator = u''.join160161162def buffereater(f):163 """
249 unmodified lines
modified:tests/runtime/bigtable.py+10 added-9 removed
8 unmodified lines
910import cgi11import sys12import timeit13import jdebug14from StringIO import StringIO1516from genshi.builder import tag17from genshi.template import MarkupTemplate
31 unmodified lines
49if have_django:50 django_tmpl = DjangoTemplate("""51<table>52{% for row in table %}52<tr>{% for col in row.values %}{{ col|escape }}{% endfor %}</tr>53<tr>{% for col in row.values %}{{ col }}{% endfor %}</tr>54{% endfor %}55</table>56""")5758jinja_tmpl = Environment().from_string('''59<table>59{% for row in table %}60<tr>{% for col in row.values() %}{{ col|escape }}{% endfor %}</tr>60{% for row in table -%}61<tr>{% for col in row.values() %}{{ col }}{% endfor %}</tr>62{% endfor %}63</table>64''')6566cheetah_tmpl = CheetahTemplate('''66# filter escape67<table>68#for $row in $table69<tr>70#for $col in $row.values()
9 unmodified lines
80<table>81% for row in table:82<tr>83% for col in row.values():84 ${col|h}84 ${col}85% endfor86</tr>87% endfor88</table>
47 unmodified lines
136if __name__ == '__main__':137 which = [arg for arg in sys.argv[1:] if arg[0] != '-']138139 if '-p' in sys.argv:140 import hotshot, hotshot.stats141 prof = hotshot.Profile("template.prof")142 benchtime = prof.runcall(run, which, number=1)143 stats = hotshot.stats.load("template.prof")140 from cProfile import Profile141 from pstats import Stats142 p = Profile()143 p.runcall(test_jinja)144 stats = Stats(p)145 stats.strip_dirs()146 stats.sort_stats('time', 'calls')147 stats.print_stats()148 else:
1 unmodified line