W3C home > Mailing lists > Public > www-style@w3.org > November 2002

Macros for CSS

From: Etan Wexler <ewexler@stickdog.com>
Date: Wed, 6 Nov 2002 18:35:03 -0500
Message-Id: <v03102806b9e82416a20a@[64.24.91.50]>
To: www-style@w3.org

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:17 GMT