HTML wrappers [AEK 01621-0]
It's a common thruth that sharing content is better than duplicating it. Usually, almost all pages of a given website share common layout, stylesheets, scripts and background images. Images, scripts and stylesheets can be (and are in most cases) extracted into separate files which are separatelly cached so that the client does not have to download exactly same bytes hundreeds of times. What about common layout? Unfortunatelly not!
Once W3C proposed a solution: XSLT templates which can be attached to an XHTML file as an outer stylesheet. Unfortunatelly they are even more clumsy, overengeneered and unhuman(readable) than XHTML2, so virtually nobody used them. XHTML2 never took off and was superseded by lightweight HTML5. It's time to replace XSLT by a lightweight solution.
We propose to introduce new optional attribute “wrapper” to the <html> tag and new block elements <blob> to the <head> section. If the “wrapper” attribute is nonzero, load the template, replace the <<body>> placeholder with content of the document and <<id>> placeholders with the content of blobs with corresponding ids from the head of the document. Merge the rest of the document's head into the template's header. Templates can be nested, so process the template's “wrapper” attribute.
This should cover at least 99% of common use cases. The rest can be handled with javascript.
It's a common thruth that sharing content is better than duplicating it. Usually, almost all pages of a given website share common layout, stylesheets, scripts and background images. Images, scripts and stylesheets can be (and are in most cases) extracted into separate files which are separatelly cached so that the client does not have to download exactly same bytes hundreeds of times. What about common layout? Unfortunatelly not!
Once W3C proposed a solution: XSLT templates which can be attached to an XHTML file as an outer stylesheet. Unfortunatelly they are even more clumsy, overengeneered and unhuman(readable) than XHTML2, so virtually nobody used them. XHTML2 never took off and was superseded by lightweight HTML5. It's time to replace XSLT by a lightweight solution.
The document | The template |
---|---|
<html wrapper="/template/common"> <head> <title>Contacts</title> <blob id="alternate-languages"> <li><a href="?lang=ru">ru</a> <li><a href="?lang=de">de</a> </blob> </head> <dl> <dt>Tel:</dt> +49 11223344 <dt>E-Mail:</dt> bla@bla.com </dl> ... </html> | <html> <head> <link rel="stylesheet" href="/style/theme.css"/> ... </head> <nav> ... </nav> <aside> <ul> <<alternate-languages>> <ul> </aside> <<body>> </html> |
This should cover at least 99% of common use cases. The rest can be handled with javascript.