My favorites | Sign in
Project Logo
                
People details
Project owners:
  girvanliu

Sopily is a PHP Template Engine that is a good alternative of Smarty, it has following features:

It is easy and fast. Just try it.

Related link: 中文版介紹 http://dev.sopili.net/2009/04/sopily-php-template-engine.html

Demo

Main Script: index.php

$url='http://software.sopili.net/';
require_once('Sopily.class.php');
$sopily=new Sopily;
$sopily->template_dir="/home/www/sopily/demo";
$sopily->assign('url',$url);
$sopily->display('index_tpl.php');

Template: index_tpl.php

<? 
require('header_tpl.php');  //relative path, indicated by $sopily->template_dir
?>
<h1>Demo</h1>
url is <?=$url?> <br>
url with modifier <?=$_escape($url)?> <br>
url with multiple modifier: <?=sopily($url,Array('default'=>'http://www.sopili.net >_<|||','escape'))?> <br>
url with multiple modifier2: <?=sopily($url,'default','http://www.sopili.net')?> <br>
url with multiple modifier3: <?=$_escape($url)?> <br>
url with multiple modifier4: <?=$_escape($url,'html')?> <br>


<?
require('footer_tpl.php');  
?>

Benchmark

Get memory usage by memory_get_usage(). Get per requests time by apache benchmark. Scripts were modified from Demo file of Smarty.

Methods\template Sopily Template Lite Smarty
Memory (compiled/normal) 707760 747496 992488
Memory (Force Compile) 707760 1345944 1952440
Memory (Cached) 251544 447688 584768
Time per request (Cached) 7.734 12.922 14.891
Time per request (compiled/normal) 37.118 48.438 46.719

The structure of Sopily is simple, so it is the fastest one.









Hosted by Google Code