templates.php 435 B

1234567891011121314151617181920
  1. <?php
  2. function getTemplate ($template, $folder=__DIR__."/") {
  3. $file = $folder.$template;
  4. $content = "";
  5. if (is_file($file)) {
  6. $content = file_get_contents($file);
  7. } else {
  8. error_log('Not file....'.$file);
  9. }
  10. return $content;
  11. }
  12. function parseTemplate ($template, $context) {
  13. $final = $template;
  14. foreach ($context as $key => $value){
  15. $final = str_replace('{'.$key.'}',$value, $final);
  16. }
  17. return $final;
  18. }