2012-02-07 37 views
-1

我真的搜索,但什麼也沒找到。Php - 模板精簡版

我是模板精簡版新手。我添加了我的項目template_lite庫,我有兩個文件。

test.php的是:

require("../src/class.template.php"); 
$tpl = new Template_Lite; 
$tpl->compile_dir = "compiled/"; 
$tpl->compile_dir = "templates/"; 
$tpl->assign("foo","bar"); 

和我有簡單的HTML,看看我的代碼

<html> 
<head> 
<title>Document Title</title> 
</head> 
<body> 
{$foo} 
</body> 
</html> 

它打印 「{$ FOO}」 不會吧,爲什麼:S

+1

你放置一個HTML頁面.tpl內以適當的目錄? – Scott 2012-02-07 00:33:07

+0

您是否在任何地方定義了$ foo? – 2012-02-07 00:35:23

+0

如何將html放在.tpl中:S是.tpl必不可少的? – 2012-02-07 00:41:02

回答

0

你似乎缺少對display()的呼叫。一個typical template sample需要以下

// test.php 
require("../src/class.template.php"); 
$tpl = new Template_Lite; 
$tpl->compile_dir = "compiled/"; 
$tpl->compile_dir = "templates/"; 
$tpl->assign("foo","bar"); 

$tpl->display("test.tpl"); 

templates/test.tpl

<html> 
<head> 
<title>Document Title</title> 
</head> 
<body> 
{* this is a comment *} 
{ $foo } 
</body> 
</html> 

模板在您的瀏覽器請求的URL將test.php

+0

我的錯誤是調用test.html而不是test.php謝謝 – 2012-02-07 00:58:19