This shows you the differences between the selected revision and the current version of the page.
| a_simple_example_using_phpsavant | a_simple_example_using_phpsavant 2007/08/31 21:40 current | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | This is a simple example to illustrate some simple concepts. | ||
| + | ===== The PHP File ===== | ||
| + | |||
| + | <code php> | ||
| + | <?php | ||
| + | |||
| + | include_once( 'php-stl/Compiler.php' ); | ||
| + | include_once( 'php-stl/Tag.php' ); | ||
| + | include_once( 'php-stl/CoreTag.php' ); | ||
| + | include_once( 'Savant3.php' ); | ||
| + | |||
| + | Compiler::SetCompileDirectory( 'compiled' ); | ||
| + | |||
| + | $template = new Savant3(); | ||
| + | $template->setCompiler( 'Compiler' ); | ||
| + | |||
| + | $template->addPath( 'template', '../common/' ); | ||
| + | |||
| + | $template->assign( 'name', '<your-name-here>' ); | ||
| + | $template->assign( 'email', 'kidkill@whatbadgerseat.com' ); | ||
| + | |||
| + | $template->display( 'simple.xml' ); | ||
| + | |||
| + | ?> | ||
| + | </code> | ||
| + | |||
| + | ===== The Template ===== | ||
| + | |||
| + | <code xml> | ||
| + | <?xml version="1.0" encoding="UTF-8"?> | ||
| + | <template xmlns:c = "class://CoreTag"> | ||
| + | <p>Hello, <c:out value = "${this.name}" /></p> | ||
| + | <p><a href = "mailto:${=this.email}">I'll mail you at ${=this.email}</a></p> | ||
| + | </template> | ||
| + | </code> | ||
| + | |||
| + | ===== The Output ===== | ||
| + | |||
| + | <code html> | ||
| + | <p>Hello, <your-name-here></p> | ||
| + | <p><a href = "mailto:kidkill@whatbadgerseat.com">I'll mail you at kidkill@whatbadgerseat.com</a></p> | ||
| + | </code> | ||