Mercurial > genshi > genshi-test
diff markup/eval.py @ 120:eb6cead67474
* Allow `py:with` directives to define `lambda`s
* Fix directive order so that a `py:for` loop can be used inside a `py:when` or `py:otherwise` branch.
author | cmlenz |
---|---|
date | Wed, 02 Aug 2006 11:56:31 +0000 |
parents | 226613431921 |
children | 203f459e7e26 ce04d361f894 |
line wrap: on
line diff
--- a/markup/eval.py +++ b/markup/eval.py @@ -76,17 +76,19 @@ def __repr__(self): return '<Expression "%s">' % self.source - def evaluate(self, data): + def evaluate(self, data, nocall=False): """Evaluate the expression against the given data dictionary. @param data: a mapping containing the data to evaluate against + @param nocall: if true, the result of the evaluation is not called if + if it is a callable @return: the result of the evaluation """ retval = eval(self.code, {'data': data, '_lookup_name': _lookup_name, '_lookup_attr': _lookup_attr, '_lookup_item': _lookup_item}) - if callable(retval): + if not nocall and callable(retval): retval = retval() return retval