Macros for CSS

The recent discussion of multi-property declarations [1] prompted some
thought on a generalized macro scheme for property values.

Naturally, we would need a way to define macros and a way to invoke them.
Consider the following syntactical definitions for an at-rule to define
macros.

macro-rule
  : MACRO_SYM b+ IDENT b*
    '{' [ any | block | ATKEYWORD b* ]+ '}'
  ;
b
  : [ S | COMMENT ]
  ;

"@macro"    {return MACRO_SYM;}

Now consider usage scenarios.  People could use macros to stand for entire
values, as in the following rules.

@macro big-length {1em}
e { padding-top: macro(big-length); }

However, people could also use macros to stand for just part of a value, as
in the following rules.

@macro small-length {0.1em}
e { border-spacing: 0.25em macro(small-length); }

More likely to arise in actual use is something like the following rules.

@macro big-length {1em}
@macro small-length {0.1em}
table { border-spacing: macro(small-length) macro(big-length); }
th, td { padding: macro(big-length) macro(small-length); }

There is some flexibility in our choice of invocation syntax, so let us not
fret over the one in my example.  The definition syntax, on the other hand,
will need to be of the block form in order to accomodate the full range of
core syntax property values.

[1]  Christopher Lee.
"[Suggestion] Multiple 'property' tokens in 'declaration' syntax".
29 August 2002.
<mid:20020829115408.47515.qmail@web13605.mail.yahoo.com> /
<http://lists.w3.org/Archives/Public/www-style/2002Aug/0379.html>.

--
Etan Wexler <mailto:ewexler@stickdog.com>

Received on Wednesday, 6 November 2002 18:52:25 UTC