Following the discussion in #48 and having slept on it, I think the best solution for syntax would be to avoid the </> implied closing tags, and instead follow the actual HTML5 spec for tags.
Self-closing tags
The following elements wouldn't require the closing tailing slash /> and would be forbidden from having child nodes:
Aside from being closed by the opening tags mentioned above (if any), those elements are closed if their parent elements are closed (including implicit closing of the parent element).
All tags close on termination
To top it all of all open tags would automatically close at the end of the view! macro invocation.
Examples
All these rules combined would mean the following would all be valid syntax:
view! {
<table.some-class>
<tr>
<td> "Row 1, Col 1"
<td> "Row 1, Col 2"
<td> "Row 1, Col 3"
<tr>
<td> "Row 2, Col 1"
<td> "Row 2, Col 2"
<td> "Row 2, Col 3"
}
This should all be backwards compatible with what's currently implemented, though it adds ambiguity to closing tags making implicit closing </> unfeasible (and also unnecessary I believe).
In addition components would still have to follow the XML rules for closing since there is no way for the macro to know whether a component allows closing tags or not.
Following the discussion in #48 and having slept on it, I think the best solution for syntax would be to avoid the
</>
implied closing tags, and instead follow the actual HTML5 spec for tags.Self-closing tags
The following elements wouldn't require the closing tailing slash
/>
and would be forbidden from having child nodes:<area>
<base>
<br>
<col>
<embed>
<hr>
<img>
<input>
<link>
<meta>
<source>
<track>
<wbr>
Optional closing tags
The following elements would would have their closing tags made optional altogether:
<html>
<head>
<body>
<p>
closed by many other elements<dt>
closed by<dd>
or<dt>
<dd>
closed by<dd>
or<dt>
<li>
closed by<li>
<rp>
closed by<rt>
or<rp>
<rt>
closed by<rt>
or<rp>
<caption>
<colgroup>
<thead>
closed by<tbody>
or<tfoot>
<tbody>
closed by<tbody>
or<tfoot>
<tfoot>
<tr>
closed by<tr>
<td>
closed by<td>
or<th>
<th>
closed by<td>
or<th>
<optgroup>
closed by<optgroup>
<option>
closed by<option>
or<optgroup>
Aside from being closed by the opening tags mentioned above (if any), those elements are closed if their parent elements are closed (including implicit closing of the parent element).
All tags close on termination
To top it all of all open tags would automatically close at the end of the
view!
macro invocation.Examples
All these rules combined would mean the following would all be valid syntax:
This should all be backwards compatible with what's currently implemented, though it adds ambiguity to closing tags making implicit closing
</>
unfeasible (and also unnecessary I believe).In addition components would still have to follow the XML rules for closing since there is no way for the macro to know whether a component allows closing tags or not.
CC: @nanoqsh