Example #1
0

<?php 
require_once 'common.php';
/**
 * Create DarwinTpl instance
 *
 */
$templatesDir = __DIR__ . DS . 'templates';
$template = new \Darwin\DarwinTpl($templatesDir);
/*
 * When using main layout it's necessary to specify blocks.
 * for every block of data.
 *
 * Blocks can be nested and can be overrided.
 *
 * Please take a look to the layout file and template file
*/
$template->render('layouts');
Example #2
0

<?php 
require_once 'common.php';
$templatesDir = __DIR__ . DS . 'templates';
/**
* The parials directory.
*/
$partialsDir = $templatesDir . DS . 'partials';
/**
 * Create DarwinTpl instance
 *
 */
$template = new \Darwin\DarwinTpl($templatesDir, $partialsDir);
$data = array('occupation' => 'Web developer', 'nationality' => 'Earthian', 'contact' => array('phone' => '777555777', 'email' => '*****@*****.**'));
$template->render('partials', $data);
//, $data);
Example #3
0

<?php 
require_once 'common.php';
/**
 * Create DarwinTpl instance
 *
 */
$templatesDir = __DIR__ . DS . 'templates';
$template = new \Darwin\DarwinTpl($templatesDir);
/**
 * To add a variable you can simply use the assign mthod as follows.
 */
$template->assign('name', 'Jhon Doe');
$data = array('occupation' => 'Web developer', 'nationality' => 'Earthian', 'contact' => array('phone' => '777555777', 'email' => '*****@*****.**'));
/*
 We can use the assign method as follows

$thi->template->assign('data, $data'); //the data will stored in an array $data.

or Simple pass the data to the template when rendered.
*/
$maliciousCode = "<script type='text/javascript'>alert('Hacked');</script>";
$template->assign('maliciousCode', $maliciousCode);
$template->render('variables', $data);
Example #4
0

<?php 
require_once 'common.php';
/**
 * Create DarwinTpl instance
 *
 */
$templatesDir = __DIR__ . DS . 'templates';
$template = new \Darwin\DarwinTpl($templatesDir);
/**
 * rendering template
 */
$template->render('basic');
//$assetsDir = __DIR__.DS.'assets';
//$baseURL = '//' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
//$template->addPlugin( new \src\plugins\Asset( $assetsDir, $baseURL ) );
//$template->assign('name', 'Jhon Doe');
//$template->render('test');
Example #5
0
* Example from the Asset plugin
*  public function init(&$template)
{
$template->register('asset', $this, 'asset');
$template->register('css', $this, 'css');
$template->register('js', $this, 'js');
}
*
*
*
*
*/
require_once 'common.php';
/**
 * Create DarwinTpl instance
 *
 */
$templatesDir = __DIR__ . DS . 'templates';
$template = new \Darwin\DarwinTpl($templatesDir);
$assetsDir = __DIR__ . DS . 'assets';
$baseURL = '//localhost/anis/darwintpl/samples';
/**
 * Adding the asset plugin to DarwinTpl's instance.
 */
$template->addPlugin(new \Darwin\Plugins\Asset($assetsDir, $baseURL));
/**
 * rendering template
 */
$template->render('plugins');
$parts = parse_url($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], PHP_URL_HOST);
print_r($parts);