W3C home > Mailing lists > Public > www-style@w3.org > May 2012

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Sat, 26 May 2012 12:14:35 -0700
Message-ID: <CAAWBYDCYAMSr0ehU9ytx6vHUTDs0CEKUujHH=vgGXXLeFcH33Q@mail.gmail.com>
To: Pete Boere <pete@the-echoplex.net>
Cc: www-style@w3.org
On Sat, May 26, 2012 at 12:09 PM, Pete Boere <pete@the-echoplex.net> wrote:
> From the perspective of PHP (and perl or bash) scripters, dollars in CSS
> would create everyday problems.
>
> Heredocs:
>
> print <<<CSS
> <style>
> p {
> color: $bar;
> }
> </style>
> CSS;

Instead, do:

?>
<style>
p {
color: $bar;
}
</style>
<?php

Jumping into the HTML-output mode is good for outputting HTML.


> I'm not sure what is supposed to happen with CSS variables used in inline
> styles, but variable interpolation when printing html attributes is very
> common in PHP:
>
> echo "<hr style='color: $foo;' />";

echo "<hr style='color: \$foo;' />";

Or use a single-quoted string.  Alternately, use a proper library for
constructing and outputting HTML, rather than string concat.

~TJ
Received on Saturday, 26 May 2012 19:15:25 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:54 GMT