PHP模板语言 Twig

openkk 13年前
     <p><img title="PHP模板语言 Twig" border="0" alt="PHP模板语言 Twig" src="https://simg.open-open.com/show/122fb7bdf112a4f3186bed3927c4df5f.gif" width="400" height="195" /><br /> Twig是一个灵活,快速,安全的PHP模板语言。它将模板编译成经过优化的原始PHP代码。Twig拥有一个Sandbox模型来检测不可信的模板代码。Twig由一个灵活的词法分析器和语法分析器组成,可以让开发人员定义自己的标签,过滤器并创建自己的DSL。</p>    <ul>     <li><strong>快速</strong>: Twig <em>compiles</em> templates down to plain optimized PHP code. The overhead compared to regular PHP code was reduced to the very minimum. </li>     <li><strong>安全</strong>: Twig has a <em>sandbox</em> mode to evaluate untrusted template code. This allows Twig to be used as a template language for applications where users may modify the template design. </li>     <li><strong>灵活</strong>: Twig is powered by a flexible <em>lexer</em> and <em>parser</em>. This allows the developer to define its own custom tags and filters, and create its own DSL. </li>    </ul>    <p></p>    <p>示例模板:</p>    <p>{% extends "layout.html" %}<br /> <br /> {% block content %}<br />   Content of the page...<br /> {% endblock %}</p>    <br />    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1322983785765" target="_blank">http://www.open-open.com/lib/view/home/1322983785765</a></p>