public function testGetParemeterString() { $view = new \figdice\View(); $view->loadString('<fig:template>' . '<fig:feed class="\\ParamTest3Feed" param1="\'a\'" target="data" />' . '<fig:mute fig:text="/data"/>' . '</fig:template>'); $this->assertEquals('ab', $view->render()); }
// /document/css/textColor $view->mount('document', array('title' => 'My first FigDice exercise', 'css' => array('textColor' => '#dd22aa'))); // Mount some more data into our View. // They could come from a database, for example. // NB: You can mount Objects! provided that the properties you want to // expose, have a getter method (or are public). class MyUser { // This public property is accessible from your template public $firstname; // This private property is automatically made accessible by the getTitle method. private $title; public function __construct($title, $firstname) { $this->title = $title; $this->firstname = $firstname; } public function getTitle() { return $this->title; } } $view->mount('userDetails', new MyUser('Mr', 'Gabriel')); // Render the template! try { $output = $view->render(); } catch (\figdice\exceptions\FileNotFoundException $ex) { die('some include went wrong at rendering-time: ' . PHP_EOL . $ex->getMessage()); } echo $output; // Typically to the browser, or into a file for caching purposes, etc.