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

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 UTC