Guest User

http://stackoverflow.com/questions/11198221/defining-variabl

a guest
Feb 12th, 2013
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2. // Tested with https://github.com/leafo/lessphp/tree/21a012ff48b289e3e500ebd7c45ca90d5acbd39c
  3. require "lessc.inc.php";
  4. $less = new lessc;
  5. // Compile example from http://stackoverflow.com/a/11198338/938089
  6. echo $less->compile(<<<FOOD
  7. @red-md:   #232;
  8. @red-dk:   #343;
  9.  
  10. .setColor(@color) {
  11.     (~"body.@{color}") { background-color: ~"@{@{color}-dk}";
  12.         #container { background-color: ~"@{@{color}-md}";
  13.          p { color: ~"@{@{color}-md}"; }
  14.       }
  15.     }
  16. }
  17. .setColor("red"); // Quotes, or the value is parsed as "#FF0000" instead of "red"
  18. //.setColor("blue"); etc..
  19. FOOD
  20. );
  21.  
  22. // Will output
  23. //body.red {
  24. //  background-color: #343;
  25. //}
  26. //body.red #container {
  27. //  background-color: #232;
  28. //}
  29. //body.red #container p {
  30. //  color: #232;
  31. //}
Add Comment
Please, Sign In to add comment