A modest collection of PHP libraries used at SparkFun.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
756 B

  1. <?php
  2. namespace SparkLib;
  3. use \SparkLib\Renderable;
  4. /**
  5. * Sparkdown macro base class.
  6. *
  7. */
  8. class SparkdownMacro implements Renderable {
  9. protected $_input;
  10. protected $_context = [];
  11. public function __construct ($input)
  12. {
  13. $this->_input = $input;
  14. }
  15. /**
  16. * Takes things that should be available when the macro is rendered,
  17. * for passing into templates or whatever.
  18. *
  19. * @return SparkdownMacro
  20. */
  21. public function setContext (array $context)
  22. {
  23. $this->_context = $context;
  24. return $this;
  25. }
  26. /**
  27. * Get the current context array.
  28. *
  29. * @return array
  30. */
  31. public function getContext ()
  32. {
  33. return $this->_context;
  34. }
  35. public function render ()
  36. {
  37. return '<p>' . $this->_input . '</p>';
  38. }
  39. }