phptal / PHPTAL

PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages
http://phptal.org
GNU Lesser General Public License v2.1
176 stars 42 forks source link

`tal:attributes` booleans not set properly, do not validate #8

Closed ajcrites closed 11 years ago

ajcrites commented 12 years ago

If you set a boolean attribute on an element using tal:attributes, it will use the value of the variable instead of setting the boolean value. This results in invalid HTML for that attribute.

The boolean attribute list is also incomplete for HTML5, but that is probably a separate issue.

To reproduce, use code/template like this:

$tpl->boolat = true;
<!DOCTYPE html>
<html>
   <head><title>Boolean Not setting</title></head>
   <body>
      <input tal:attributes="disabled boolat" />
   </body>
</html>

When the template is emitted, it will specify disabled="1", and this does not validate at least for HTML5. If you set a boolean attribute without using tal:attributes, it will be set properly.

tanakahisateru commented 12 years ago

This issue looks sharing the same problem with #10. Did you intend?

ajcrites commented 12 years ago

This issue is not the same as #10. There is no overlap between the issues. My sample code uses disabled to exhibit the behavior, but disabled is already on the current DOM Node List, so fixing the list will not fix this issue.

It may be debatable that this is an issue at all, but I feel that tal:attributes should set boolean values properly if the output mode is HTML.

tanakahisateru commented 12 years ago

I understand what you mean. <input disabled> was expected but actually <input disabled="1">, although disabled attribute defined.

Does below test explain what you mentioned? https://github.com/pornel/PHPTAL/blob/html5_with_ns/tests/TalAttributesTest.php#L178

ajcrites commented 12 years ago

Yes, that is correct.

tanakahisateru commented 11 years ago

Fixed in #12 .