PHP模板語言 Twig
Twig是一個靈活,快速,安全的PHP模板語言。它將模板編譯成經過優化的原始PHP代碼。Twig擁有一個Sandbox模型來檢測不可信的模板代碼。Twig由一個靈活的詞法分析器和語法分析器組成,可以讓開發人員定義自己的標簽,過濾器并創建自己的DSL。
- 快速: Twig compiles templates down to plain optimized PHP code. The overhead compared to regular PHP code was reduced to the very minimum.
- 安全: Twig has a sandbox 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.
- 靈活: Twig is powered by a flexible lexer and parser. This allows the developer to define its own custom tags and filters, and create its own DSL.
示例模板:
{% extends "layout.html" %}
{% block content %}
Content of the page...
{% endblock %}
本文由用戶 openkk 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!