灵感来源于jQuery和React的API的HTML渲染库

2.0.0 2023-11-16 14:14 UTC

This package is auto-updated.

Last update: 2024-09-16 19:23:50 UTC


README

Source Code Latest Version Software License Build Status Coverage Status Quality Score

框架无关的HTML渲染工具,API灵感来源于jQuery和React。

简短介绍

$h = new Sirius\Html\Builder;

$h->registerTag('user-login-form', 'MyApp\Html\Components\UserLoginForm');

echo $h->make('user-login-form', ['_form_values' => $_POST]);

它将输出类似以下内容

<form method="post" action="user/login" class="form form-inline">

<div class="form-control">
    <label for="email">Email/Username:</label>
    <input type="email" name="email" id="email" value="me@domain.com">
</div>

<!-- the rest of the form goes here -->

</form>

性能

这里有一个简单的 基准测试,渲染一个包含4个字段和一个按钮的表单。与Twig相比,Sirius HTML速度慢50%,但内存使用量减少2倍。

对于100K次迭代的基准测试结果如下

当然,这并不是真实世界场景,但它可以给你一个对这个库的期望。

链接