On
https://github.com/pivotal/erector/issues/20 Macario Ortega and I just had an interesting discussion about "naked attributes" aka "HTML5 Mode" in Haml.
The gist is that naked attributes look cool, but browsers don't see any difference between this
<input type="text" required>
and this
<input type="text" required="true" />
Although it would be somewhat more standard if Erector did this:
<input type="text" required="required" />
Perhaps if the attribute value is true (not just truish, but the boolean true) then it should use the name of the attribute, rather than true.to_s.
We also came up with a (arguably) nice Erector/Ruby idiom for conditional attributes, in this case based on a boolean method:
input :type => 'text', :required => required? or nil
That way even if required? is false, it'll become nil, which will omit the attribute altogether.
--
Alex Chaffee -
al...@stinky.comhttp://alexchaffee.comhttp://twitter.com/alexch