定制 softwarezhu/pate 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 softwarezhu/pate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-2.1
  • 更新时间: 2017-03-17