ichigotake/nano-template

Nano template engine with PHP5 language

dev-master 2013-12-07 02:52 UTC

This package is not auto-updated.

Last update: 2025-06-16 18:59:48 UTC


README

NanoTemplate - Nano template engine with PHP5 language

USAGE

All function in example. This module is verrrry simply!

very simply call

require 'lib/NanoTemplate.php';

# render($view_file, $binds, $charset);
# 
# The second and the following arguments is optional.
# Default charset is "UTF-8"
render('/path/to/view.php', array(
    'greet' => 'hahaha',
    'greet_jp' => 'ごきげんよう',
));

or, make instance

### index.php
# param(optional): ($view = 'view/', $charset = 'UTF-8')
$t = new NanoTemplate('view/');

# echo template with bind variable
$t->render('template.php', array(
    'greet'    => 'Hello!!',
    'greet_jp' => 'こんにちは!',
));

### view/template.php
<?php $_layout = 'layout.php' ?>

<?php echo $greet_jp ?> (Japanese mean "<?php echo $greet ?>")

### view/layout.php
<!doctype html>
<html>
<head>
</head>
<body>
    <?php echo $_content ?>
</body>
</html>

Why naming Nano?

PHP template engine is already many exists. but almost theres is large or Web Application Framework dependencies.

NanoTemplate don't have expand syntax and assigned vars are not '$this'. also, if you want to assign object vars ;)

NanoeTemplate has only 1 pure PHP file. PHP is template engine it self, because nameing 'Nano'.

AUTHOR

ichigotake

LICENSE

MIT LICENSE