I'm working on a new big PHP / Symfony 2 project and decided to use Sass / SCSS and Compass which I found both really awesome for managing CSS in a modern way. However, there's still one problem for which I couldn't find any answer: how to place PHP variables in original SCSS files and make them preserved in output CSS files?
This is not a detail, because without this functionality there's no way to interface Sass generated stylesheets with PHP, which could be really limitating in some big projects.
To be clear, and as a starting point, in a classic way we can interface CSS with PHP mainly like this :
<link type="text/css" href="layout.css.php?my_var=#CC0000" rel="stylesheet" />
and then in a pseudo CSS file layout.css.php like in the example above:
<?php header("Content-type: text/css");?>
.my_color {
background-color:<?=$_GET['my_var']?>;
}
Now, how can I do something equivalent in SCSS / Compass? In other words, how to place some PHP vars in original SCSS files that will be kept as is in the final CSS output file, so that it could be further parsed in real time with PHP like in the example above?
When I try to do this Compass and SASS compilers fail because of the PHP syntax.
Phamlp has some filters for PHP that only apply to haml templates, not SCSS files.
LESSphp seems to have such functionality, but lots of people seem to be moving from LESS to SCSS / Compass, so what is the best approach?
Many thanks.