-------------------
- webhelpers.html._literal
* Implementation of 'literal' moved to this private module.
* New method .lit_join() works like .join() but does not escape the parts.
- webhelpers.html.builder:
* 'HTMLBuilder.\_\_call\_\_()' accepts keyword args 'nl' and 'lit'. If 'nl'
is true, add a newline after each element. If 'lit' is true, don't escape
the elements when joining them.
* 'HTMLBuilder.literal()' is the 'literal' class constructor. As a
consequence it no longer accepts multiple positional args.
Use '.\_\_call\_\_()' with 'lit=True' as an alternative.
* '.comment()' adds a space before and after the content.
* 'HTMLBuilder.void_tags' is a set of tag names to render in the self-closing
style because they can never have content. It replaces the 'empty_tags'
global. Add HTML 5 tags to list: "command", "keygen", "source".
* 'HTMLBuilder.compose_attrs' is a dict of attribute names to string
separators. If the tag method is called with any of these attributes and
their value is a list or tuple, join the elements into a string using this
separator. The separators should be literals.
* 'HTMLBuilder.boolean_attrs' is a set of attribute names which are
converted to HTML boolean syntax if passed to the tag method. The current
set is a conservative few commonly used in tags: "defer", "disabled",
"multiple", "readonly". You can pass additional ones for a specific tag
as the "\_bool" argument to ``HTML.tag()``.
* There doesn't seem to be an authoritative list of all boolean attributes;
here are some lists on the web:
http://stackoverflow.com/questions/706384/boolean-html-attributes
https://github.com/kangax/html-minifier/issues/63
We're evaluating whether to include all these. We're also evaluating
whether it's better to convert them globally in any tag they appear in,
or to convert some of them on a tag-by-tag basis. As far as we can tell,
any attribute that's boolean in one case is boolean everywhere; we haven't
seen any attribute that's boolean in one tag but non-boolean in another
tag.
* 'HTMLBuilder' has several literal constants as class attributes: EMPTY,
SPACE, TAB2, TAB4, NL, BR, NL2, BR2.
* Bugfixes:
+ Convert None to "" when passed to constructor.
+ Pass attribute when raising AttributeError.
+ ``re.sub`` overescapes in Python 3 if the third argument (the
original string) is a literal, so convert it to a plain string.
* Implementation changes:
+ '.comment()' is now a regular method.
+ Replace UnfinishedTag with functools.partial.
+ Delete UnfinishedComment, UnfinishedLiteral, UnfinishedTag.
+ Refactor methods to call self instead of doing ad hoc joins.
+ Merge 'make_tag()' into 'HTMLBuilder.tag()'. Make it call 'self' rather
than joining strings.
+ Move 'empty_tags' to 'HTMLBuilder.void_tags'.
+ Move part of 'format_attrs()' to 'HTMLBuilder.optimize_attrs()', and
merge '_attr_decode()' into it, and also None value handling. Move the
compose dict local variable to a class attribute 'compose_attrs'.
+ Implement boolean attribute conversion in 'HTMLBuilder.optimize_attrs()'.
+ Refactor 'format_attrs()' to 'HTMLBuilder.render_attrs()'. Change the
argument to a dict instead of keyword args. Delete the None handling
because 'HTMLBuilder.optimize_attrs()' now does it.
- webhelpers.html.tags:
* New class 'Link' is like 'link_to_if' but is lazily evaluated.
* Delete 'title()'. It's too specific for a general-purpose library.
* Delete 'xml_declaration()'.
* Delete 'convert_boolean_attrs()' and 'css_classes()'. The HTML builder
now does these itself.
* When 'link_to_if' and 'link_to_unless' return just the label, escape it.
Tag functions are always supposed to return literals.
* The 'id_format' argument to the 'ModelTags' constructor now uses "{}"
string formatting. It still accepts "%s" for backward compatibility and
converts it to the newer format.
* Add a space between the widget and the label when rendering 'checkbox()'
or 'radio()' with the 'label' argument.
* 'checkbox()' and 'radio()' have a new keyword argument 'label_class'.
This sets the <label>'s class attribute.
* Bugfixes:
+ Python 3's 'map()' behavior broke 'select()'.
* Implementation changes:
+ Call 'HTML.tag()' rather than attribute access for a slight performance
improvement.
+ Input helpers call '_input()' to render themselves. It subsumes the
old '_set_input_attrs()' code.
- webhelpers.html.tools:
* New home for 'update_params()'. Beta 1 had left it in the
'unfinished' directory.
* Implementation changes:
+ Unpack nested tag expression in 'button_to()'.
- Port doctests in 'html' subpackage to unit tests.