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

In sass, variables have two modes.

1. As in theproposal by Tab, they can be used in any value context and their data type is preserved.
2. In non-value contexts (properties, selectors), there is a macro-expansion phase where variables (and other script expressions) can be evaluated and cast to a string before they are parsed. To do this, sass has an escape sequence of #{}. Which is a syntax that derives from its ruby-based roots.

To be honest, I don't think the variables proposal, being cascade based, is at all compatible with non-value use-cases.

But it doesn't really matter unless Mixins or some sort of in-browser macro expansion phase comes along. I was under the impression these were extremely unlikely.  Maybe Tab has a grand vision for how this spec would integrate with mixins that I can't see. 


Hunt & pecked on my iPhone... Sorry if it's brief!

On May 23, 2012, at 5:32 PM, Brian Kardell <bkardell@gmail.com> wrote:

> Interesting, I never would have expected that to work, I wonder how many people would.  Earlier in this thread[1], marat also suggested this:
> 
>     /* Using compact $bp as property name instead of long 'background-position' */
>     .foo {$bp: center; }
> 
> I also didn't expect that to work (don't see how it could if that is the syntax for assignment), regardless of the syntax, but no one seems to have addressed it.  I think it is as interesting and maybe as valid as interpolated strings... no?
> 
> [1] http://lists.w3.org/Archives/Public/www-style/2012May/0782.html
> 
> On May 23, 2012 8:23 PM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:
> On Wed, May 23, 2012 at 5:18 PM, Liam R E Quin <liam@w3.org> wrote:
> > On Wed, 2012-05-23 at 12:54 -0700, Tab Atkins Jr. wrote:
> >> [...]
> >
> >> Variables can hold any value,
> >> including values that contain commas.
> >
> > Presumably they can also hold $ signs too.
> 
> Kinda.  When I change the spec to explicitly define the value-space,
> unrestricted DELIM tokens won't be allowed.  However, var references
> can be - they're expanded at computed-value time (the only thing
> that's ever "resolved" in a variable before it's used in a property).
> 
> > Is the ${name} syntax also allowed? e.g.
> >
> >   content: "hello ${var1}000 and ${var2}nospaceafter";
> 
> No, they can only be used as component values right now, so they can't
> be used within strings.  That's an interesting use-case, though.
> 
> ~TJ
> 

Received on Thursday, 24 May 2012 01:05:42 UTC