<?php
/*
* SCORE ( 18 pts )
*
* file : 1
* statements : 11
* variables : 6 (arrays and class instance are counted as a variable)
*/
/*
* We use the PHP's autoload function to load dynamicaly classes.
*/
require_once("autoload.php");
/*
* We use a template engine because as you know it is far better
* to use MVC :-)
*/
require_once("lib/twig/lib/Twig/Autoloader.php");
Twig_Autoloader::register();
/*
* We create a new Twig Environment with debug and templates cache.
*/
$twig = new Twig_Environment(
new Twig_Loader_Filesystem(
"design/templates" /* The place where to look for templates */
),
array(
'debug' => true,
'cache' => 'var/cache/templates'
)
);
/*
* We add the debug extension because we should be able to detect what is wrong if needed
*/
$twig->addExtension(new Twig_Extension_Debug());
/*
* We create a new page to be displayed in the body.
*/
$page = new Page();
/*
* We add our famous title : Hello World !!!
*/
$page->add( 'Title', array( 'level' => 1, 'text' => 'Hello World' ) );
/*
* We are now ready to render the content and display it.
*/
$final_result = $twig->render(
'pages/hello_world.twig',
array(
'Page' => $page->toXML()
)
);
/*
* Everything is OK, we can print the final_result to the page.
*/
echo $final_result;
?>