Skip to content
Myr

[svn] checkpoint

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 cd80053 · Browse files · 5 files+44 added−15 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+44 added−15 removed

  • other:+44 added−15 removed

5 files+44 added−15 removed

modified:docs/src/designerdoc.txt+1 added
609 unmodified lines
610 also defines the content that fills the hole in the *parent*. If there were611 two similarly-named ``{% block %}`` tags in a template, that template's612 parent wouldn't know which one of the blocks' content to use.613614615Super Blocks616============617618Starting with `Jinja 1.1` it's possible to render the contents of the parent
474 unmodified lines
modified:jinja/translators/python.py+2 added-4 removed
229 unmodified lines
230 #: mapping of unsupported syntax elements.231 #: the value represents the feature name that appears232 #: in the exception.233 self.unsupported = {234 ast.ListComp: 'list comprehensions',235 ast.From: 'imports',236 ast.Import: 'imports',234 ast.ListComp: 'list comprehensions'235 }236237 #: because of python2.3 compatibility add generator238 #: expressions only to the list of unused features
166 unmodified lines
405 # load the template we inherit from and add not known blocks406 parent = self.environment.loader.parse(node.extends.template,407 node.filename)408 # look up all block nodes in the current template and411 # add them to the override dict409 # add them to the override dict.410 for n in get_nodes(nodes.Block, node):411 overwrites[n.name] = n412 # handle direct overrides413 for n in get_nodes(nodes.Block, parent):
829 unmodified lines
modified:jinja/filters.py+13 added-6 removed
120 unmodified lines
121 return e(s, attribute)122 return wrapped123124125def do_xmlattr():125def do_xmlattr(autospace=False):126 """127 Create an SGML/XML attribute string based on the items in a dict.128 All values that are neither `none` nor `undefined` are automatically129 escaped:130131 .. sourcecode:: html+jinja132133 <ul {{ {'class': 'my_list', 'missing': None,133 <ul{{ {'class': 'my_list', 'missing': None,134 'id': 'list-%d'|format(variable)}|xmlattr }}>135 ...136 </ul>137
4 unmodified lines
142 <ul class="my_list" id="list-42">143 ...144 </ul>145146 As you can see it automatically appends a space in front of the item147 if the filter returned something. You can disable this by passing148 `false` as only argument to the filter.149150 *New in Jinja 1.1*151 """152 e = escape153 def wrapped(env, context, d):
5 unmodified lines
159 result.append(u'%s="%s"' % (160 e(env.to_unicode(key)),161 e(env.to_unicode(value), True)162 ))159 return u' '.join(result)163 rv = u' '.join(result)164 if autospace:165 rv = ' ' + rv166 return rv167 return wrapped168169170def do_capitalize(s):
150 unmodified lines
321 def wrapped(env, context, seq):322 try:323 return iter(seq).next()324 except StopIteration:318 return env.undefined_singleton[0]325 return env.undefined_singleton326 return wrapped327328329def do_last():
3 unmodified lines
333 def wrapped(env, context, seq):334 try:335 return iter(_reversed(seq)).next()336 except StopIteration:330 return env.undefined_singleton[-1]337 return env.undefined_singleton338 return wrapped339340341def do_random():
3 unmodified lines
345 def wrapped(env, context, seq):346 try:347 return choice(seq)348 except IndexError:342 return env.undefined_singleton[0]349 return env.undefined_singleton350 return wrapped351352353def do_urlencode():
507 unmodified lines
modified:jinja/nodes.py+28 added-4 removed
28 unmodified lines
29 node.lineno = offset30 todo.extend(node.getChildNodes())313233def get_nodes(nodetype, tree):33def get_nodes(nodetype, tree, exclude_root=True):34 """35 Get all nodes from nodetype in the tree.35 Get all nodes from nodetype in the tree excluding the36 node passed if `exclude_root` is `True` (default).37 """38 if exclude_root:39 todo = tree.getChildNodes()40 else:37 todo = [tree]41 todo = [tree]42 while todo:43 node = todo.pop()44 if node.__class__ is nodetype:45 yield node46 todo.extend(node.getChildNodes())474849def get_nodes_parentinfo(nodetype, tree):50 """51 Like `get_nodes` but it yields tuples in the form ``(parent, node)``.52 If a node is a direct ancestor of `tree` parent will be `None`.5354 Always excludes the root node.55 """56 todo = [tree]57 while todo:58 node = todo.pop()59 if node is tree:60 parent = None61 else:62 parent = node63 for child in node.getChildNodes():64 if child.__class__ is nodetype:65 yield parent, child66 todo.append(child)676869class Node(ast.Node):70 """71 Jinja node.72 """
40 unmodified lines
113 return [self.format_string] + list(self.variables)114115 def __repr__(self):116 return 'DynamicText(%r, %r)' % (93 self.text,117 self.format_string,118 self.variables119 )120121
300 unmodified lines
modified:jinja/parser.py-1 removed
529 unmodified lines
530 plural = u''.join(plural)531 return nodes.Trans(flineno, singular, plural, indicator,532 replacements or None)533534534 def parse_python(self, lineno, gen, template):535 """536 Convert the passed generator into a flat string representing537 python sourcecode and return an ast node or raise a
229 unmodified lines