** file: mycss.php **
<? $mycolor = "blue"; ?>** file: index.php **
.myclass {
font-size: 12pt;
color: <? echo $mycolor ?>
}
<html>This works because PHP is interpreting the CSS file as if it were PHP code. After it interprets it, what is left is CSS code and thanks to the type directive in the link tag, that is how it is rendered by the browser. Hence, no need for an additional file that does a massive search and replace. An online example can be found at my site.
<head>
<link rel="stylesheet" href="mycss.php" type="text/css">
<body>
<span class="myclass">Hello world!</span>
</body>
</html>
The next challenge for me is to get something like this working in Ruby on Rails.
No comments:
Post a Comment