0

I have the following pcode written in twig:

<input type="checkbox" name="fc[fully_completed]" id="fully_completed" onclick="this.form.submit();"
            {% if fully_completed is not null %}
                checked="checked"
            {% endif %}

>

I use mtHamlBundle and i need to write the same part of code in haml. But I ran into a problem that I can not figure out how to set attribute "checked" as in the first example. And the same problem is with javascript in attribute "onclick".

Does anyone know the solution to this problem?

Ivan Kuzyshyn
  • 165
  • 1
  • 1
  • 7

1 Answers1

0
%input{ fully_completed ? {checked: "checked"} : {}}

Taken from https://coderwall.com/p/_jiytg/conditional-html-tag-attribute-in-haml

jfxninja
  • 371
  • 3
  • 11