Want more features on Pastebin? Sign Up, it's FREE!
Guest

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

By: a guest on Feb 12th, 2013  |  syntax: PHP  |  size: 0.76 KB  |  views: 45  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. //}
clone this paste RAW Paste Data