shish / microhtml
一个最小化HTML生成库
v2.2.1
2023-08-17 16:39 UTC
Requires
- php: ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.12
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.0
README
从Hack迁移到vanilla PHP,我怀念XHP T__T
这不是XHP,但它提供了一种在一致且安全的方式下生成HTML的最小化无废话方法
<?php use function MicroHTML\{HTML,SECTION,H1,P,DIV}; $page = HTML( SECTION(["id"=>"news"], H1("My title"), P("Here's some content") ) ); $page->appendChild( SECTION(["id"=>"comments"], DIV("Oh noes: <script>alert('a haxxor is attacking us');</script>") ) ); print($page);
<html> <section id='news'> <h1>My title</h1> <p>Here's some content</p> </section> <section id='comments'> <div>Oh noes: <script>alert('a haxxor is attacking us');</script></div> </section> </html>
测试
composer install
./vendor/bin/php-cs-fixer fix
./vendor/bin/phpunit tests
./vendor/bin/phpstan analyse src tests --level 5
发布
git tag v1.2.3
git push --tags