有一个烧瓶 wtforms 选择字段并尝试合并 htmx ajax 调用,它在数据属性中有破折号,所以我在 SO 上找到了一个解决方案,如下所示:
{{ form.dia(class="form-select", **{'hx-post': "/pulleys/{{pulley_id}}/hub_type", 'hx-target': "#hub-shaft-selection", 'hx-swap': "innerHTML"}) }}
但是模板没有解析{{pulley_id}},我猜它已经在另一个{{}}中了。有没有一种方法可以构建如上所示的动态部分,所以它最终成为
'hx-post'="/pulleys/1/hub_type"
当 pulley_id=1 完全渲染时