However, this isn’t possible when a PHP statement defines if the input is supposed to be checked as the HTML will naturally already be compiled when the PHP is executed.
-# The following will cause the input to be always marked as checked
-# as an empty string is also considered as TRUE
= php "$checked = $a == $b ? 'checked' : ''"
%input(input type="radio" name="foo" checked="#{ php("echo $checked") }")
-# The Haml parser does not allow for attributes without value
= php "$checked = $a == $b ? 'checked=\"checked\"' : ''"
%input(input type="radio" name="foo" #{ php("echo $checked") })
-# Error: Invalid attribute list: "(input type=\"radio\" name=\"foo\" \#{ php(\"echo $checked\") })".
To get this to work at all atm., one has to resolve to pure HTML which is plain nasty:
In HTML(5) the following are equal and all mark the element as checked.
Haml allows to set a boolean as value which will cause the attribute to show up or not.
However, this isn’t possible when a PHP statement defines if the input is supposed to be checked as the HTML will naturally already be compiled when the PHP is executed.
To get this to work at all atm., one has to resolve to pure HTML which is plain nasty: