|
UsageExamples
How to set up a running system
Usage ExamplesIt is simple to set up a running system with the serpent template engine. Here are some examples which should be a good base for your own integration. For a detailed description of all parameters and methods take a look a the API. Simple ExampleThis is the simplest way. It assumes that your template "base.tpl" is utf-8 encoded. directory structure index.php
serpent/
source/*
templates/
base.tpl
templates_compiled/index.php // init serpent
include('serpent/serpent.class.php');
$serpent = new serpent();
echo $serpent->render('base');base.tpl Hello World! Advanced ExampleThis is a more advanced examples with many more set parameters. directory structure as in the simple example above index.php // init serpent
$serpent = new serpent();
$serpent->compile_dir = $dir.'templates_compiled/';
$serpent->force_compile = true;
$serpent->default_resource = 'file';
$serpent->default_compiler = 'serpent';
$serpent->setCharset('utf-8');
// init resource
$serpent->addPluginConfig('resource', 'file', array(
'template_dir' => $dir.'templates/',
'suffix' => '.tpl',
'language' => 'de'
));
// render template with data
$vars = array('world'=>'World!');
$serpent->pass($vars);
echo $serpent->render('base');base.tpl Hello ~~$world~ |
Sign in to add a comment
Hinter der $serpent->addPluginConfig Anweisung fehlen zwei Klammern ));
Ups...:) thank you. Added.