function test_flexy() { // define object and properties // corresponding to template variables $page = new stdClass(); $page->items = array('Eggs', 'Bread', 'Milk', 'Bacon', 'Cornflakes'); $flexy = Gloo_Flexy::getInstance(); $flexy->compile('test.tmpl'); $flexy->outputObject($page); }
static function getInstance() { if (self::$instance == NULL) { // set template options //@see also http://pear.php.net/manual/en/package.html.html-template-flexy.configuration.php $options = array('templateDir' => $_SERVER['GLOO_WEB_DIR'] . 'templates', 'compileDir' => $_SERVER['GLOO_WEB_DIR'] . 'templates_c', 'compiler' => 'Flexy', 'locale' => 'en', 'debug' => 0); // initialize template engine $flexy = new HTML_Template_Flexy($options); self::$instance = $flexy; } return self::$instance; }
function execute($payload) { //fetch data array $videos = array(); $video1 = new UIX_VO_Video(); $video1->title = 'Youtube video1'; $video2 = new UIX_VO_Video(); $video2->title = 'Youtube video2'; array_push($videos, $video1); array_push($videos, $video2); $output = NULL; //foreach data array object // compile a template using flexy // get output from flexy $flexy = Gloo_Flexy::getInstance(); $flexy->compile('video.tmpl'); //View object is stdClass ,i.e. PHP base class $view = new stdClass(); //$videos is an array of $video objects $view->videos = $videos; $page->orgKey = "xvcgffh192828272"; $output = $flexy->bufferedOutputObject($view); return $output; }