PHP Classes

File: templating_engine/functions/php_templator.php

Recommend this page to a friend!
  Classes of jon   PHP Templating Engine   templating_engine/functions/php_templator.php   Download  
File: templating_engine/functions/php_templator.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Templating Engine
Process templates in PHP, JSON and CSS formats
Author: By
Last change: Update of templating_engine/functions/php_templator.php
Date: 1 year ago
Size: 1,566 bytes
 

Contents

Class file image Download
<?php

function php_templator($file_type, $file_contents, $V)
{
    if(
$file_type === 'css')
    {
       
$string = str_replace('(', '<?= $', $file_contents);
       
$string = str_replace(')', '; ?>', $string);
       
$string = str_replace('S[', '_SESSION[\'', $string);
       
$string = str_replace(']S', '\']', $string);
    }
    elseif(
$file_type === 'json')
    {
       
$string = str_replace('"{', '"<?= $', $file_contents);
       
$string = str_replace('}"', '; ?>"', $string);
       
$string = str_replace('S[', '_SESSION[\'', $string);
       
$string = str_replace(']S', '\']', $string);
    }
    else
    {
       
$string = str_replace('{', '<?= $', $file_contents);
       
$string = str_replace('}', '; ?>', $string);
       
$string = str_replace('S[', '_SESSION[\'', $string);
       
$string = str_replace(']S', '\']', $string);
    }

   
file_put_contents('tmp.php', $string);

   
ob_start();
   
    include(
'tmp.php');
   
   
$string = ob_get_clean();

    if(
$file_type === 'css')
    {
       
$string = '<style>'.$string.'</style>';
    }
   
    return
$string;
}

   
/*
$string = str_replace('<ar', '<article', $string);
$string = str_replace('<b', '<button', $string);
$string = str_replace('<c', '<content', $string);
$string = str_replace('<d', '<div', $string);
$string = str_replace('</ar', '</article', $string);
$string = str_replace('</b', '</button', $string);
$string = str_replace('</c', '</content', $string);
$string = str_replace('</d', '</div', $string);
*/

?>