Alexander Kuklev (akuklev) wrote,
Alexander Kuklev
akuklev

Memo

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.


The documentThe 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>
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.
Tags: webtech
Subscribe

  • (no subject)

    Встретил фотографию толпы футбольных фанатов, и она меня скорее напугала, у меня уж точно нет желания быть там среди них. Но внезапно я понял, что…

  • Прогресс

    Десять дней назад, вторая ступень SpaceX'овского корабля Starship своим ходом слетала своим ходом на десять километров вверх, и усмепшно приземлилась…

  • О водосбережении

    Как известно, питьевая вода во многих странах дефицитный ресурс. И даже в дождливой Германии летом иногда случаются засухи, в результате которых она…

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments