2013年8月27日

on
一、Dwoo v1.1.1 取得:
1.官方網站:
http://dwoo.org/
2.檔案下載:http://dwoo.org/download/dwoo-v1-1-1/download/0
3.說明文件:http://wiki.dwoo.org/index.php/Main_Page

二、Dwoo 特色:
1.類似Smarty 樣版引擎,且與Smarty樣版、外掛相容。
  Dwoo 大部分應用都與Smarty雷同。僅部分保留變數,未被Dwoo採納。
  如:{section},{sectionelse} 用{for},{forelse}取代。
  資料參考:http://wiki.dwoo.org/index.php/SmartySupport

2.可用於:CodeIgniter(CI)、Zend Framework、Yii Framework..等。

3.速度與佔用記憶體比較:(
Smarty vs. Smarty 3 vs. Template Lite vs. Dwoo)
  a.Smarty 3 最慢和佔用最多記憶體。Dwoo 最快,但是比Template Lite佔用記憶體多。
  b.Smerty 3 比Smarty 2 慢,且佔用更多記憶體。不覺得Smarty 3 有做到哪些改善...在測試版發行前,他們需要更努力些。

三、Dwoo 第一次使用:
1.目錄規劃:
Project - include – dwoo 
        - cache (自訂快取目錄,預設在Dwoo\cache 目錄中)
        - templates (自訂樣版儲存位置)
        - templates_c (自訂樣版編譯後儲存位置,預設在Dwoo\Compiled 目錄中)

2.Dwoo 初始化與取得自訂目錄位置示範:
demo.php
<?php define("CACHE_Dir", "cache/");
define("TEMPLATES_Dir", "templates/");
define("TEMPLATES_C_Dir", "templates_c/");
ini_set('include_path',ini_get('include_path') . ';./include');
require_once('dwoo/dwooAutoload.php');
$dwoo = new Dwoo();
$dwoo->setCacheDir(CACHE_Dir); //設定自訂快取目錄位置
$dwoo->setCompileDir(TEMPLATES_C_Dir);
 
//設定自訂樣版編譯後儲存位置
$dwoo->setCacheTime(600);
$data = new Dwoo_Data();
$data->assign('fCache_Dir', $dwoo->getCacheDir());
$data->assign('fCompile_Dir', $dwoo->getCompileDir());
$tpl = new Dwoo_Template_File(TEMPLATES_Dir.'demo.tpl.htm');
$dwoo->output($tpl, $data);
//或改為
//$dwoo->output(TEMPLATES_Dir.'demo.tpl.htm',$data);

?>


demo.tpl.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo</title>   
</head>
    <body>
        <ul>
            <li>快取目錄位置:{$fCache_Dir}</li>
            <li>編譯目錄位置:{$fCompile_Dir}</li>            
        </ul>
    </body>
</html>

0 意見:

張貼留言

注意:只有此網誌的成員可以留言。