thenlabs/nate
Composer 安装命令:
composer require thenlabs/nate
包简介
A Twig-inspired template engine which take adventage of native PHP features.
README 文档
README
A Twig-inspired template engine which take adventage of native PHP features.
If you know Twig, you know Nate.
If you like this project gift us a ⭐.
Quick reference.
| Nate | Twig |
|---|---|
<?= $this->data ?> |
{{ data }} |
<?= $this->data->raw() ?> |
{{ data|raw }} |
<?php $this->extends('base.nate.php') ?> |
{% extends 'base.html.twig' %} |
<?php $this->block('name') ?> |
{% block name %} |
<?php $this->endblock() ?> |
{% endblock %} |
<?php if ($condition) : ?> |
{% if condition %} |
<?php foreach($array as $key => $value) : ?> |
{% for key, value in array %} |
<?= $this->includeTemplate('another.nate.php', ['data' => 'value']) ?> |
{{ include('another.html.twig', {data: 'value'}) }} |
Installation.
$ composer require thenlabs/nate dev-main
Usage example.
base.nate.php:
<!DOCTYPE html> <html lang="<?= $this->lang ?>"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title><?= $this->title ?></title> <?php $this->block('styles') ?> <?php $this->endblock() ?> </head> <body> <?php $this->block('body') ?> <?php $this->endblock() ?> <?php $this->block('scripts') ?> <?php $this->endblock() ?> </body> </html>
page.nate.php:
<?php $this->extends('base.nate.php') ?> <?php $this->block('styles') ?> <link rel="stylesheet" href="style.css"> <?php $this->endblock() ?> <?php $this->block('body') ?> <p>This is a paragraph.</p> <?php $this->endblock() ?> <?php $this->block('scripts') ?> <script src="scripts.js"></script> <?php $this->endblock() ?>
index.php:
<?php use ThenLabs\Nate\Template; $page = new Template(__DIR__.'/page.nate.php'); echo $page->render([ 'lang' => 'en', 'title' => 'My Title', ]);
Output:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My Title</title> <link rel="stylesheet" href="style.css"> </head> <body> <p>This is a paragraph.</p> <script src="scripts.js"></script> </body> </html>
Development.
Clone this repository and install the Composer dependencies.
$ composer install
Running the tests.
All the tests of this project was written with our testing framework PyramidalTests wich is based on PHPUnit.
Run tests:
$ composer test
thenlabs/nate 适用场景与选型建议
thenlabs/nate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「template」 「template-engine」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 thenlabs/nate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 thenlabs/nate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 thenlabs/nate 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provides ProcessWire integration for various template engines such as Twig.
Enable Laravel Blade Template Engine for Kirby 4 and Kirby 5
Simple ASCII output of array data
Type-safe Twig views with template validation and testing capabilities
E2E Studios PHP Framework adaptation of leafsphp/blade package
A symfony bundle for kharhamel/office-template-engine
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-19