StringLoader.php 972 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of Mustache.php.
  4. *
  5. * (c) 2013 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * Mustache Template string Loader implementation.
  12. *
  13. * A StringLoader instance is essentially a noop. It simply passes the 'name' argument straight through:
  14. *
  15. * $loader = new StringLoader;
  16. * $tpl = $loader->load('{{ foo }}'); // '{{ foo }}'
  17. *
  18. * This is the default Template Loader instance used by Mustache:
  19. *
  20. * $m = new Mustache;
  21. * $tpl = $m->loadTemplate('{{ foo }}');
  22. * echo $tpl->render(array('foo' => 'bar')); // "bar"
  23. */
  24. class Mustache_Loader_StringLoader implements Mustache_Loader
  25. {
  26. /**
  27. * Load a Template by source.
  28. *
  29. * @param string $name Mustache Template source
  30. *
  31. * @return string Mustache Template source
  32. */
  33. public function load($name)
  34. {
  35. return $name;
  36. }
  37. }