1234567891011121314151617181920 |
- <?php
- function getTemplate ($template, $folder=__DIR__."/") {
- $file = $folder.$template;
- $content = "";
- if (is_file($file)) {
- $content = file_get_contents($file);
- } else {
- error_log('Not file....'.$file);
- }
- return $content;
- }
- function parseTemplate ($template, $context) {
- $final = $template;
- foreach ($context as $key => $value){
- $final = str_replace('{'.$key.'}',$value, $final);
- }
- return $final;
- }
|