V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
爱意满满的作品展示区。
Tianpu

PHP: Onion Template Engine

  •  
  •   Tianpu · Sep 1, 2015 · 2698 views
    This topic created in 3894 days ago, the information mentioned may be changed or developed.

    https://github.com/tianpu/onion

    优势

    1. 模板直观,就是最终的 html 加上必要的标记
    2. 语法简单,只支持 unit (块元素), list (列表), this (静态变量)三种语法
    3. 洋葱一样的嵌套结构,支持任意多层嵌套(由于实现简单,当前 unit 下级关键字需要唯一)

    使用

    $tmpl = 'sample'; //模板名称,示例为 sample.html
    $data = array (); //渲染数据,示例数据在 sample.php
    $html = html_render ($tmpl,$data );
    /*
    缓存为 md5 ($tmpl ),首次运行自动生成缓存文件
    默认不自动销毁缓存文件或者监控模板文件更改,需要手工删除 tmp 目录下缓存文件
    */
    

    版权

    MIT

    5 replies    2015-09-04 10:14:42 +08:00
    miao
        1
    miao  
       Sep 1, 2015
    请问是干嘛的? 模板引擎?
    mogita
        2
    mogita  
       Sep 1, 2015
    就喜欢这种简单粗暴的!
    yangg
        3
    yangg  
       Sep 1, 2015
    注释都是灰色的这样真的好么
    jinzhe
        4
    jinzhe  
       Sep 2, 2015
    不错,怎么没有 if 之类的,这样实用性更好些
    isCyan
        5
    isCyan  
       Sep 4, 2015 via iPhone
    看起来的确比大括号舒服啊
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   831 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 21:12 · PVG 05:12 · LAX 14:12 · JFK 17:12
    ♥ Do have faith in what you're doing.