Symfony Twig + Haml 标签属性检查和属性脚本
Symfony Twig + Haml tag attribute check and attribute script
我用 twig 编写了以下代码:
<input type="checkbox" name="fc[fully_completed]" id="fully_completed" onclick="this.form.submit();"
{% if fully_completed is not null %}
checked="checked"
{% endif %}
>
我使用 mtHamlBundle,我需要在 haml 中编写相同的代码部分。
但是我 运行 遇到了一个问题,我不知道如何像第一个例子那样设置属性 "checked" 。同样的问题是属性 "onclick" 中的 javascript。
有人知道这个问题的解决方法吗?
%input{ fully_completed ? {checked: "checked"} : {}}
取自https://coderwall.com/p/_jiytg/conditional-html-tag-attribute-in-haml
我用 twig 编写了以下代码:
<input type="checkbox" name="fc[fully_completed]" id="fully_completed" onclick="this.form.submit();"
{% if fully_completed is not null %}
checked="checked"
{% endif %}
>
我使用 mtHamlBundle,我需要在 haml 中编写相同的代码部分。 但是我 运行 遇到了一个问题,我不知道如何像第一个例子那样设置属性 "checked" 。同样的问题是属性 "onclick" 中的 javascript。
有人知道这个问题的解决方法吗?
%input{ fully_completed ? {checked: "checked"} : {}}
取自https://coderwall.com/p/_jiytg/conditional-html-tag-attribute-in-haml