(template, **kwargs)
| 469 | |
| 470 | |
| 471 | def template_eval(template, **kwargs): |
| 472 | start = '<%' |
| 473 | end = '%>' |
| 474 | escaped = (re.escape(start), re.escape(end)) |
| 475 | mark = re.compile('%s(.*?)%s' % escaped, re.DOTALL) |
| 476 | for key in kwargs: |
| 477 | exec('%s = %s' % (key, kwargs[key])) |
| 478 | for item in mark.findall(template): |
| 479 | template = template.replace(start + item + end, |
| 480 | str(eval(item.strip()))) |
| 481 | return template |
| 482 | |
| 483 | |
| 484 | def run(p): |