+ Moved variables resolution in the compiler Parser. (Temp. solution until the new...
[haanga.git] / examples / django-yui.php
blob2443c2681a1b9d9b8343f6718f4b246859fd8ca4
1 <?php
3 require "../lib/Haanga.php";
4 $config = array(
5 'cache_dir' => 'tmp/',
6 'template_dir' => 'django-yui-layout-templates/',
7 );
9 if (is_callable('xcache_isset')) {
10 /* don't check for changes in the template for the next 5 min */
11 $config['check_ttl'] = 300;
12 $config['check_get'] = 'xcache_get';
13 $config['check_set'] = 'xcache_set';
16 Haanga::Configure($config);
18 $files = array();
19 foreach (glob("django-yui-layout-templates/*.html") as $html) {
20 if (is_file($html)) {
21 $files[basename($html)] = TRUE;
25 if (!isset($_GET['layout']) || !isset($files[$_GET['layout']])) {
26 $_GET['layout'] = key($files);
29 $blocks = array(
30 '1' => 'Content on div 1',
31 '2' => 'Content on div 2',
32 '3' => 'Content on div 3',
33 '4' => 'Content on div 4',
34 'title' => $_GET['layout']." template",
37 $debug = TRUE;
38 $sql_queries = array(
39 array('sql' => 'select * from foobar', 'time' => '1'),
40 array('sql' => 'select * from php', 'time' => '1'),
43 $files = array_keys($files);
44 $time = microtime(TRUE);
45 $mem = memory_get_usage();
47 Haanga::Load($_GET['layout'], compact('debug', 'files', 'sql_queries'), FALSE, $blocks);
48 var_dump(array(
49 'memory (mb)' => (memory_get_usage()-$mem)/(1024*1024),
50 'time' => microtime(TRUE)-$time
51 ));