Kod
#!/bin/bash
mkdir public templates templates_c public/action public/view
chmod 777 templates_c
touch index.php public/action/akcja.php public/view/index.php templates/page.tpl
mkdir public templates templates_c public/action public/view
chmod 777 templates_c
touch index.php public/action/akcja.php public/view/index.php templates/page.tpl
A zawartość to:
/public/action/akcja.php
<?php $tpl->assign( 'test', true ); return 'view/index'; ?>
/public/view/index.php
<?php $template = 'page.tpl'; ?>
/templates/page.tpl
/index.php
<?php require_once( 'smarty/Smarty.class.php' ); function run( $req ) { $tpl =& new Smarty; $req = include( APPDIR . 'public/' . $req . '.php' ); return $tpl->fetch( $template ); } ?>
Przykład jest banalnie prosty. Chyba jednak nie do końca potrafię zrozumieć jego potencjał (o ile takowy istnieje). Na ile można coś takiego wykorzystać?