Mercurial > hg
comparison mercurial/templater.py @ 12402:b014f998959d
templater: add a few comments.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Tue, 21 Sep 2010 23:55:32 +0200 |
parents | d4cafcb63f77 |
children | ea3bada953d3 |
comparison
equal
deleted
inserted
replaced
12401:4cdaf1adafc8 | 12402:b014f998959d |
---|---|
136 | 136 |
137 expr = tmpl[pos + 1:n] | 137 expr = tmpl[pos + 1:n] |
138 pos = n + 1 | 138 pos = n + 1 |
139 | 139 |
140 if '%' in expr: | 140 if '%' in expr: |
141 # the keyword should be formatted with a template | |
141 key, t = expr.split('%') | 142 key, t = expr.split('%') |
142 parsed.append((self._format, (key.strip(), | 143 parsed.append((self._format, (key.strip(), |
143 self._load(t.strip())))) | 144 self._load(t.strip())))) |
144 elif '|' in expr: | 145 elif '|' in expr: |
146 # process the keyword value with one or more filters | |
145 parts = expr.split('|') | 147 parts = expr.split('|') |
146 val = parts[0].strip() | 148 val = parts[0].strip() |
147 try: | 149 try: |
148 filters = [self._filters[f.strip()] for f in parts[1:]] | 150 filters = [self._filters[f.strip()] for f in parts[1:]] |
149 except KeyError, i: | 151 except KeyError, i: |
150 raise SyntaxError(_("unknown filter '%s'") % i[0]) | 152 raise SyntaxError(_("unknown filter '%s'") % i[0]) |
151 parsed.append((self._filter, (filters, val))) | 153 parsed.append((self._filter, (filters, val))) |
152 else: | 154 else: |
155 # just get the keyword | |
153 parsed.append((self._get, expr.strip())) | 156 parsed.append((self._get, expr.strip())) |
154 | 157 |
155 return parsed | 158 return parsed |
156 | 159 |
157 def _process(self, parsed, mapping): | 160 def _process(self, parsed, mapping): |