(template, **kwargs)
| 1270 | |
| 1271 | |
| 1272 | def template_eval(template, **kwargs): |
| 1273 | start = '<%' |
| 1274 | end = '%>' |
| 1275 | escaped = (re.escape(start), re.escape(end)) |
| 1276 | mark = re.compile('%s(.*?)%s' % escaped, re.DOTALL) |
| 1277 | for key in kwargs: |
| 1278 | exec('%s = %s' % (key, kwargs[key])) |
| 1279 | for item in mark.findall(template): |
| 1280 | e = eval(item.strip()) |
| 1281 | template = template.replace(start + item + end, str(e)) |
| 1282 | return template |
| 1283 | |
| 1284 | |
| 1285 | def run(path: Union[Path, str]) -> str: |