| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
n7w77
9年前发布

快速和强大的PHP模板引擎:tonic

快速和强大的PHP模板引擎,能够编译成原生PHP代码。

用法

Usin

$tpl = new Tonic();  echo $tpl->load("demo.html")->assign("user_role","member")->render();

Tonic is pretty straight forward.
$tpl = new Tonic("demo.html");  $tpl->user_role = "member";  echo $tpl->render();

It's also very flexible. The above code can also be written like:

Show me the syntax

Using Tonic

<body>  <h1>Bienvenido {$user.name.capitalize().truncate(50)}</h1>  Rol de usuario: {$role.lower().if("admin","administrator").capitalize()}  </body>

vs. writting all in PHP

<body>  <h1>Bienvenido <?php echo (strlen($user["name"]) > 50 ? substr(ucwords($user["name"]),0,50)."..." : ucwords($user["name"])) ?></h1>  Rol de usuario: <?php if(strtolower($role) == "admin") { echo "Administrator" } else { echo ucwords($role) } ?>  </body>

Caching

All tonic templates are compiled back to native PHP code. It's highly recommended that you use the caching functionality so that the same template doesn't need to be compiled over and over again increasing the CPU usage on server side.

$tpl = new Tonic();  $tpl->cache_dir = "./cache/"; // Be sure this directory exists and has writing permissions  $tpl->enable_content_cache = true; // Importante to set this to true!

项目主页:http://www.open-open.com/lib/view/home/1426772653836

 本文由用户 n7w77 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1426772653836.html
tonic 模板引擎