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()); }
*/ /** * In this example we will learn to: * * - get started with the library * - load a template by its outer container file (This is not the recommended FigDice way!) * - push some data into the template * - pass objects to templates * - control the textual content of tags * - inline dynamic data into HTML attributes * - embed unparsed content */ // Autoload the Figdice lib require_once '../../vendor/autoload.php'; // Create a Fig View object $view = new \figdice\View(); // Load its main template file: try { $view->loadFile('template-main.xml'); } catch (\figdice\exceptions\FileNotFoundException $ex) { die('template file not found'); } // Mount some data into our View // these values will become available form within the template // as: /document/title // /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).