vovan-ve/html-template
Composer 安装命令:
composer require vovan-ve/html-template
包简介
Context sensitive HTML template engine
README 文档
README
Simple context sensitive HTML template engine. Yes, yet another one.
Synopsis
See an examples.
Template example:
<a href={ link } title={ title && "Foo bar: ${ title }" }>
<span id=foobar class='it parses html'>
{ description }
</span>
<span>
{# comment #}
</span>
</a>
Creating data for the template above:
use VovanVE\HtmlTemplate\runtime\RuntimeHelper; $runtime = new RuntimeHelper([ 'link' => 'http://example.com?foo=bar&lorem=ipsum#hash', 'title' => 'Lorem <ipsum> "dolor" sit amet', 'description' => function () { return 'Some <text/plain> content'; }, ]);
Run a template when everything is prepared. Here foobar is a template's name
covered by Template Provider.
echo $engine->runTemplate('foobar', $runtime);
The output for the example above (wrapped manually only here):
<a href="http://example.com?foo=bar&lorem=ipsum#hash" title="Foo bar: Lorem <ipsum> "dolor" sit amet" ><span id="foobar" class="it parses html" >Some <text/plain> content</span><span></span></a>
Template code compiles to PHP code behind the scene. It may look something like so (formatted manually only here for demonstration):
($runtime::createElement('a', [ 'href' => ($runtime->param('link')), 'title' => (!($_ta=($runtime->param('title'))) ? $_ta :(('Foo bar: '.($runtime->param('title')))) ) ], [ ($runtime::createElement('span', [ 'id' => 'foobar', 'class' => 'it parses html' ], [ ($runtime::htmlEncode(($runtime->param('description')))) ])), '<span></span>' ]))
Compiler will evaluate as much constant expressions as possible and as much as it learned to. For example, completely constant template like following:
<div>{true && 'Lorem < ipsum dolor'}</div>
will be compiled to:
'<div>Lorem < ipsum dolor</div>'
Description
TBW.
Installation
ATTENTION! While major version number is
0still there MAY be BC break changes in minor versions0.NEXT, but not in revision versions0.x.NEXT.
Install through composer:
composer require vovan-ve/html-template
or add to require section in your composer.json:
"vovan-ve/html-template": "~0.3.0"
License
This package is under MIT License
vovan-ve/html-template 适用场景与选型建议
vovan-ve/html-template 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 09 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 vovan-ve/html-template 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vovan-ve/html-template 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-09-17