cupcake-framework/cupcake2-cuprenderer

Template Engine used in PHP CupCake 2 Framework

dev-master 2014-09-01 00:32 UTC

This package is auto-updated.

Last update: 2024-09-06 08:45:22 UTC


README

CupCake2 Framework - Template Engine A Simple PHP Template Engine (oldschool style, uses good old <?php tag :)

Usage:

Your Controller File

require_once __DIR__ . '/vendor/autoload.php';

$templatesFolder = array(__DIR__.'/templates/');
$viewsFolder = array(__DIR__.'/views/');
$renderer = new CupRenderer($templatesFolder,$viewsFolder);

$renderer->setTemplateFile('my_template.php');

$bar = 'bar';

$renderer->render('myViewFile.php',array('foo'=>'Foo','bar'=>$bar));

Your TemplateFile

<!DOCTYPE HTML>
<html>     
    <head>
        <title>My Template File</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        
    </head>
    <body>
        <?php
            echo $content;
        ?>
    </body>
</html>

Your View File

<h1>Foo is <?=$foo?><h1>
<p>Bar is <?=$bar?><>

PS:

You can use it standalone with Silex :) Check the provider folder for more information.