205 if len(args) != 1: |
205 if len(args) != 1: |
206 raise error.ParseError(_("filter %s expects one argument") % n) |
206 raise error.ParseError(_("filter %s expects one argument") % n) |
207 f = context._filters[n] |
207 f = context._filters[n] |
208 return (runfilter, (args[0][0], args[0][1], f)) |
208 return (runfilter, (args[0][0], args[0][1], f)) |
209 |
209 |
|
210 def get(context, mapping, args): |
|
211 if len(args) != 2: |
|
212 # i18n: "get" is a keyword |
|
213 raise error.ParseError(_("get() expects two arguments")) |
|
214 |
|
215 dictarg = args[0][0](context, mapping, args[0][1]) |
|
216 if not util.safehasattr(dictarg, 'get'): |
|
217 # i18n: "get" is a keyword |
|
218 raise error.ParseError(_("get() expects a dict as first argument")) |
|
219 |
|
220 key = args[1][0](context, mapping, args[1][1]) |
|
221 yield dictarg.get(key) |
|
222 |
210 def join(context, mapping, args): |
223 def join(context, mapping, args): |
211 if not (1 <= len(args) <= 2): |
224 if not (1 <= len(args) <= 2): |
212 # i18n: "join" is a keyword |
225 # i18n: "join" is a keyword |
213 raise error.ParseError(_("join expects one or two arguments")) |
226 raise error.ParseError(_("join expects one or two arguments")) |
214 |
227 |