[whatwg] web preprocessing

Marnix T'Jaeckx marnix.tjaeckx at gmail.com
Mon Nov 26 23:33:05 PST 2012

I would like to propose and request a feature for the web standards. The
best way to describe it: a html preprocessor.
In a similar vein to the C preprocessor and the like, the syntax would
allow constants to be defined to be accessible across both html, css and js.
Scenario's where this is useful occur quite frequently, if not on every
webpage. For instance, when lay-out contstants need to be duplicated in css
and js, or when user messages need to be duplicated in html and js.
In many cases, code clarity and brevity would be helped as well as a
reduction in bandwidth, accordingly.

Implementations could make use of the meta elements or a new syntactic
layer could be added.

HTML head: <meta name="boxWidth" content="640"/>
CSS: #box{width:meta(boxWidth)}
 (or #box{width:meta('boxWidth')})
JS:  box.style.width=document.meta(

another example:
HTML head: <meta name="labelPlay" content="Let me hear you sing it!"/>
HTML body:  <button><meta name="labelPlay"></button>
JS:  box.innerHTML=document.meta('labelPlay');

Have a good one,
Marnix T'Jaeckx

More information about the whatwg mailing list