Subject: | Allow optional_end_tags to be set globally |
I've just spent a couple of hours trying to isolate what I thought was a
bug in HTML::Element (which I use for generating HTML, not for parsing it).
The code was effectively:
new HTML::Element('div')->push_content(
['p', 'para 1'],
new HTML::Element('input',
type => 'text',
id => 'fred'),
)->as_HTML;
To me this is pretty clearly specifying a 'p' followed by an 'input' -
if I had wanted the 'input' to be included in the 'p', I would have put
it inside the [].
So I could not understand why the 'input' was included in the 'p'. Even
when I tried not using lol notation, and wrote
new HTML::Element('p')->push_content('para 1'),
new HTML::Element('input', ...
the same happened.
Eventually I read the documentation of as_HTML more carefully, and saw
that by default it not only creates code that is broken if I happen to
have an XHTML DOCTYPE, but also converts the perfectly clear structure I
had above into something different - because it omits the closing tag on
'p'.
I cannot imagine why anybody would want to *generate* HTML without
closing tags (it's different writing it yourself) but I appreciate that
you must not change existing behaviour.
But PLEASE can you provide a configuration so that I can say at the
start of my program something like
$HTML::Element::optional_end_tags = {};
or
$HTML::dont_break_my_code = 1;
and not have to tell every call to as_HTML not to break my structure.
Thanks.