定义宏:
macros.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Micros</title>
</head>
<body>
{% macro render_element(element)%}
{%if element %}
<td>{{element| truncate(25)}}</td>
{%else%}
<td>{{element}}</td>
{%endif%}
{%endmacro%}
</body>
</html>
case.html
导入宏:
{%from "macros.html" import render_element%}
调用宏:
{{render_element(case.change_data)}}