<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阿债的山寨实验室 &#187; blitz</title>
	<atom:link href="http://blog.declab.com/tag/blitz/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.declab.com</link>
	<description></description>
	<lastBuildDate>Thu, 27 May 2010 03:45:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PHP模板引擎Blitz</title>
		<link>http://blog.declab.com/web/2008/php%e6%a8%a1%e6%9d%bf%e5%bc%95%e6%93%8eblitz/</link>
		<comments>http://blog.declab.com/web/2008/php%e6%a8%a1%e6%9d%bf%e5%bc%95%e6%93%8eblitz/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 23:54:51 +0000</pubDate>
		<dc:creator>阿债</dc:creator>
				<category><![CDATA[WEB开发]]></category>
		<category><![CDATA[blitz]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://rblog.declab.com/2008/1/php%e6%a8%a1%e6%9d%bf%e5%bc%95%e6%93%8eblitz/</guid>
		<description><![CDATA[今天试用了一个PHP的模板引擎Blitz，据说它的速度比Smarty之流快30%以上。网址在这里 [url=http://sourceforge.net/projects/blitz-templates/]Blitz[/url] Blitz是PHP的C扩展，从这个意义上说，更接近底层，有望比其他模板引擎更快。当然，模板的速度还取决于它生成中间结果、缓存数据的实现方式。如我们熟知的Smarty，它把你写的模板转成纯PHP文件保存起来。 不过这个Blitz用起来还是有些别扭的，可能是刚学的原因，我一时没明白它的循环怎么写。想想当初学Smarty，也不习惯它的循环。还是象ZendFromework这种完全就是PHP的模板好，不用再学一样语法，也不用再把模板记号再转回PHP代码；也许它没有限制你在模板里写垃圾代码，不够直观（话说回来，Smarty的循环也称不上直观！），对没写过程序的美工来说难度大了一些。 试用了一下，感觉Blitz还是很优秀的。我最感兴趣的地方：模板引擎本身是个类，你可以继承它，往里面添加自定义的属性和方法，然后用在你的模板文件里，一切都是那么自然。 我们还是举个例子吧： {{ include('header.tpl') }} {{ greeting(); }} {{ BEGIN weekday }} {{short}}： 周{{name}} {{ END }} {{ include('footer.tpl') }} No related posts. 以上关联文章由 Yet Another Related Posts Plugin 提供支持。


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>今天试用了一个PHP的模板引擎Blitz，据说它的速度比Smarty之流快30%以上。网址在这里 [url=http://sourceforge.net/projects/blitz-templates/]Blitz[/url]<br />
<span id="more-22"></span><br />
Blitz是PHP的C扩展，从这个意义上说，更接近底层，有望比其他模板引擎更快。当然，模板的速度还取决于它生成中间结果、缓存数据的实现方式。如我们熟知的Smarty，它把你写的模板转成纯PHP文件保存起来。<br />
不过这个Blitz用起来还是有些别扭的，可能是刚学的原因，我一时没明白它的循环怎么写。想想当初学Smarty，也不习惯它的循环。还是象ZendFromework这种完全就是PHP的模板好，不用再学一样语法，也不用再把模板记号再转回PHP代码；也许它没有限制你在模板里写垃圾代码，不够直观（话说回来，Smarty的循环也称不上直观！），对没写过程序的美工来说难度大了一些。<br />
试用了一下，感觉Blitz还是很优秀的。我最感兴趣的地方：模板引擎本身是个类，你可以继承它，往里面添加自定义的属性和方法，然后用在你的模板文件里，一切都是那么自然。<br />
我们还是举个例子吧：</p>
<pre lang="bash" line="1"><!-- 模板文件 test.tpl -->
{{ include('header.tpl') }}
<!-- 自定义方法 -->
{{ greeting(); }}
<!-- 循环 -->
{{ BEGIN weekday }}
{{short}}： 周{{name}}
{{ END }}
{{ include('footer.tpl') }}</pre>
<pre lang="bash" line="1"><?php //控制文件test.php
class View extends Blitz {
    function View($tplfile) { //构造方法
        parent::Blitz($tplfile);
    }

    public function greeting() {
        return "Hello";
    }
}

$week = array(
    array('name'=>'日', 'short'=>'Sun'),
    array('name'=>'一', 'short'=>'Mon'),
    array('name'=>'二', 'short'=>'Tue'),
);

$T = new View('test.tpl');
foreach($week as $w) {
    $T->block('/weekday', $w);
}
echo $T->parse();
?></pre>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://blog.declab.com/web/2008/php%e6%a8%a1%e6%9d%bf%e5%bc%95%e6%93%8eblitz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
