PHP Template Engine?

Roodo! Blog 開發日誌 的「樂多日誌開發使用相關技術」中使用了 這個 PHP Tempate Engine。

這讓我想到跟 聊到一篇很有名的文章:Templates and Template Engines

這篇文章簡單來說就是這樣:「他媽的你們這些人幹嘛叫我把 PHP 改得更快,你們用 Smarty 這類的 Template Engine 當然會慢啊! 本身就是一個 Template Engine,你用 Template Engine 去寫另外一個 Template Engine 當然會慢,怪我咧,blah blah…」(當然,文句沒有這麼粗俗 :p)

但你又不能直接開放 PHP function 給 user 用:因為 user 可以把 $__GLOBAL 裡面的變數倒出來慢慢看有什麼好玩的,或者是透過你的主機寄寄廣告信 *grin*

是一套直接使用 PHP function,但是做了合理的限制的 PHP Template Engine:

Savant is a powerful but lightweight object-oriented template system for PHP.

Unlike other template systems, Savant by default does not compile your templates into PHP; instead, it uses PHP itself as its template language so you don’t need to learn a new markup system.

比起 所產生的 loading 會比較小。

Update:才剛寫完就看到 上另外一個計畫 ,將 比較不常用的功能都拿掉,有興趣的人也可以看看。

Google Video Viewer

很多人都有提到 ,這是改自 的 plugin (所以有 source 公開在這裡 上),而 發現其中一段 code 限制只能看 video.google.com 上面的影片:

+ // Google mods
+ const char* allowed_host = “video.google.com”;
+ char * host_found = strstr(p_sys->url.psz_host, allowed_host);
+ if ((host_found == NULL) ||
+ ((host_found + strlen(allowed_host)) !=
+ (p_sys->url.psz_host + strlen(p_sys->url.psz_host)))) {
+ msg_Warn( p_access, “invalid host, only video.google.com is allowed” );
+ goto error;
+ }

於是他就寫了一個 patch 把這個 “bug” 修掉了:Google Video Viewer