Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

71 líneas
1.7 KiB

  1. <?php
  2. /**
  3. * @package Grav\Plugin\Admin
  4. *
  5. * @copyright Copyright (c) 2015 - 2023 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Plugin\Admin;
  9. use ScssPhp\ScssPhp\Compiler;
  10. use ScssPhp\ScssPhp\ValueConverter;
  11. class ScssCompiler
  12. {
  13. protected $compiler;
  14. public function compiler()
  15. {
  16. if ($this->compiler === null) {
  17. $this->reset();
  18. }
  19. return $this->compiler;
  20. }
  21. public function reset()
  22. {
  23. $this->compiler = new Compiler();
  24. return $this;
  25. }
  26. public function setVariables(array $variables)
  27. {
  28. // $parsed = ValueConverter::fromPhp($variables);
  29. $parsed = [];
  30. foreach ($variables as $key => $value) {
  31. $parsed[$key] = ValueConverter::parseValue($value);
  32. }
  33. $this->compiler()->addVariables($parsed);
  34. return $this;
  35. }
  36. public function setImportPaths(array $paths)
  37. {
  38. $this->compiler()->setImportPaths($paths);
  39. return $this;
  40. }
  41. public function compile(string $input_file, string $output_file)
  42. {
  43. $input = file_get_contents($input_file);
  44. $output = $this->compiler()->compile($input);
  45. file_put_contents($output_file, $output);
  46. return $this;
  47. }
  48. public function compileAll(array $input_paths, string $output_file)
  49. {
  50. $input = '';
  51. foreach ($input_paths as $input_file) {
  52. $input .= trim(file_get_contents($input_file)) . "\n\n";
  53. }
  54. $output = $this->compiler()->compileString($input)->getCss();
  55. file_put_contents($output_file, $output);
  56. return $this;
  57. }
  58. }