softwarezhu/pate
Composer 安装命令:
composer require softwarezhu/pate
包简介
Pate is a PHP Attribute Template Engine inspired by PHPTAL but run much faster. It use native dom to make it fast.
关键字:
README 文档
README
Pate is a PHP Attribute Template Engine inspired by PHPTAL but run much faster. It uses syntax like angular and vue, But renders on the server side. It's compatible with PHPTAL.
Why Use Pate Instead Of PHPTAL?
I use PHPTAL as our template engine in one of my Project. But is was TOO SLOW!!, and TOO COMPLICATED. So I decide to rewrite a similar Template Engine named PATE.
Here are some advantages:
- TREE times faster than PHPTAL. PHPTAL takes several seconds to render a big page(abount 150k), but PATE is more than 3 times faster.
- PATE is Extremely Extensible. PATE is designed for extensible, You can create your own Syntax to enhance PATE's feature.
- PATE is Extremely Easy. There are only 1/10 codes of PHPTAL, but much more powerful.
- PATE's compiled file is VERY READABLE. But PHPTAL's compiled file is complicated and very hard to read.
- PHPTAL is too strict with dom and variables, error occurs frequently. Pate is friendly.
Requirements
To use Pate, you need
-
PHP >= 5.4.
-
With dom extension installed.
Install
With composer
composer require softwarezhu/pate
Examples
Attributes
Template file
<html> <head> </head> <body> <img tal:attributes="src data/src; alt data/title"/> </body> </html>
Do render(ie. This template is named 'template.html')
use Pate\PateTemplate; $template = new PateTemplate(); $template->loadHtmlFile('template.html'); $content = $template->render(array( 'data' => array( 'src' => 'htttp://github.com/logo.jpg', 'title' => 'Github Logo' ) )); echo $content;
The render result will be
<html> <head> </head> <body> <img src="htttp://github.com/logo.jpg" alt="Github Logo"/> </body> </html>
Template Syntax
Attributes
<img tal:attributes="src data/src; alt data/title"/>
The img src and alt attributes will be replaced by the data['src'] value and data['title'] value. The multiple attributes use ";" to separate.
Text
<span tal:content="data/title">This content will be replaced after rendered. </span>
Loop
<tr tal:repeat="product products" tal:content="product/title">This content will be replaced by product/title after rendered. </tr>
If the count of products is N, there will be N tr lines.
If
<div tal:condition="product/isPromote" tal:content="product/discount">If product/isPromote is false, this block will be removed from the dom. </div>
tal:condition likes if in php.
Replace
<div tal:replace="123">This entire DIV will be replaced with '123'(not the inner text). </div>
softwarezhu/pate 适用场景与选型建议
softwarezhu/pate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「zope」 「template engine」 「pate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 softwarezhu/pate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 softwarezhu/pate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 softwarezhu/pate 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHPTAL is a templating engine for PHP5 that implements Zope Page Templates syntax
PHPTAL is a templating engine for PHP that implements Zope Page Templates syntax
ZTal makes integrating the PHP templating system PHPTAL into Zend Framework easy.
A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content (forked from Cyber-Duck/Silverstripe-SEO)
A Processor for Markup written in PHP. Allows extraction of Markup into a data structure, orchestrated nested manipulation of said structure, and output as (optimized) Markup.
Allow KoolReport to use twig template engine to render view
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-2.1
- 更新时间: 2017-03-17