PEAR2_Templates_Savant-0.3.2 › PEAR2_Templates_Savant-0.3.2/doc/pear2.php.net/PEAR2_Templates_Savant/examples/examples/basic.php
- PEAR2_Templates_Savant-0.3.2/
- doc/
- pear2.php.net/
- PEAR2_Templates_Savant/
- examples/
- baseball/
- examples/
- templates/
- examples/
- examples/
- PEAR2_Templates_Savant/
- pear2.php.net/
- php/
- PEAR2/
- Autoload.php
- Exception.php
- MultiErrors/
- MultiErrors.php
- Templates/
- PEAR2/
- test/
- doc/
- package.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
ini_set('display_errors',true);
error_reporting(E_ALL^E_STRICT);
require_once __DIR__.'/../../autoload.php';
// Set up a view object we'd like to display
$class = new stdClass();
$class->var1 = '<p>This is var1 inside a standard class</p>';
$savant = new \PEAR2\Templates\Savant\Main();
$savant->addTemplatePath(__DIR__ . '/templates');
// Display a simple string
echo $savant->render('<h1>Welcome to the Savant Demo</h1>');
// Display a string, in a custom template
echo $savant->render('mystring', 'StringView.tpl.php');
// Display an array
echo $savant->render(array('<ul>', '<li>This is an array</li>', '</ul>'));
// Display an object using a default class name to template mapping function
echo $savant->render($class);
// Display the object using a specific template
echo $savant->render($class, 'MyTemplate.tpl.php');
echo $savant->render('<h2>Output Filtering</h2>');
$savant->addFilters('htmlspecialchars');
// Now show an entire template with htmlspecialchars
echo $savant->render($class);
// Ok, now remove the output filters
$savant->setFilters();
highlight_file(__FILE__);
EOF
