HandlebarsLoaderArrayLoader

Handlebars Template array Loader implementation.

Defined (2)

The class is defined in the following location(s).

/vendor/calderawp/metaplate-core/vendor/xamin/handlebars.php/src/Handlebars/Loader/ArrayLoader.php  
  1. class ArrayLoader implements Loader 
  2. private $_templates; 
  3.  
  4. /** 
  5. * Create a new loader with associative array style 
  6. * @param array $templates the templates to load 
  7. */ 
  8. public function __construct(array $templates = array()) 
  9. $this->_templates = $templates; 
  10.  
  11. /** 
  12. * Add a template to list 
  13. * @param string $name template name 
  14. * @param string $template the template 
  15. * @return void 
  16. */ 
  17. public function addTemplate($name, $template) 
  18. $this->_templates[$name] = $template; 
  19.  
  20. /** 
  21. * Load a Template by name. 
  22. * @param string $name template name to load 
  23. * @throws \RuntimeException 
  24. * @return String 
  25. */ 
  26. public function load($name) 
  27. if (isset($this->_templates[$name])) { 
  28. return $this->_templates[$name]; 
  29. throw new \RuntimeException( 
  30. "Can not find the $name template" 
  31. ); 
/vendor/xamin/handlebars.php/src/Handlebars/Loader/ArrayLoader.php  
  1. class ArrayLoader implements Loader 
  2. private $_templates; 
  3.  
  4. /** 
  5. * Create a new loader with associative array style 
  6. * @param array $templates the templates to load 
  7. */ 
  8. public function __construct(array $templates = array()) 
  9. $this->_templates = $templates; 
  10.  
  11. /** 
  12. * Add a template to list 
  13. * @param string $name template name 
  14. * @param string $template the template 
  15. * @return void 
  16. */ 
  17. public function addTemplate($name, $template) 
  18. $this->_templates[$name] = $template; 
  19.  
  20. /** 
  21. * Load a Template by name. 
  22. * @param string $name template name to load 
  23. * @throws \RuntimeException 
  24. * @return String 
  25. */ 
  26. public function load($name) 
  27. if (isset($this->_templates[$name])) { 
  28. return $this->_templates[$name]; 
  29. throw new \RuntimeException( 
  30. "Can not find the $name template" 
  31. );