Re: [css-variables] Using $foo as the syntax for variables

On Wed, May 23, 2012 at 11:11 AM, Ojan Vafai <ojan@chromium.org> wrote:
> On Wed, May 23, 2012 at 10:32 AM, Tab Atkins Jr. <jackalmage@gmail.com>
> wrote:
>> The only two extensions I know I want right now are (1) the ability to
>> specify a default value to be used when a var is invalid or undefined,
>> and (2) the ability to grab the value of a variable from the parent
>> (the inherited value) rather than from the current element.
>>
>> Under the current syntax, these would look something like this:
>>
>> color: var(bar) // normal
>> color: var(bar, red) // default value
>> color: parent-var(bar) // bar from the parent
>> color: parent-var(bar, red) // bar from the parent, with a default value
>>
>> In the new syntax, it would look something like this:
>>
>> color: $bar //normal
>> color: default-var($bar, red) // default value
>
> This could still be var($bar, red) and var($bar) could still work. $bar
> could just be an alais for it. Any subset of these options for dealing with
> default values seem fine to me.

Hm, good point.  No reason to use an extra-long name if a shorter one will do.


>> color: parent-var($bar) // bar from the parent
>> color: parent-var($bar, red) // bar from the parent, with a default value
>
> The new syntax looks strictly better. It prioritizes making the common case
> more readable (or at least more concise) and easier to use without making
> the less common cases any worse.

That's my argument, yeah.

~TJ

Received on Wednesday, 23 May 2012 18:26:52 UTC