zamasskin/html-constructor
Composer 安装命令:
composer require zamasskin/html-constructor
包简介
Html engine components
README 文档
README
Instead of writing HTML or using an HTML templating engine, you compose your layout using PHP structures with the dash-html-components library.
Installation
Install composer.
Run the following in the root of your project:
composer require zamasskin/html-constructor dev-main
Or, create a composer.json file with the following contents and run "composer install":
{
"require": {
"zamasskin/html-constructor": "dev-main"
}
}
Usage
<?php use HtmlConstructor\Tags; require_once "vendor/autoload.php"; $html = (new Tags\TextContent\Div()) ->style("color: red; background: #000") ->className("parent") ->children([ (new Tags\TextContent\Div())->className("one"), (new Tags\TextContent\Div())->className("two"), ]); echo $html->render(); // <div style="color: red; background: #000" class="parent"><div class="one"></div><div class="two"></div></div> $html = Tags::Div()->className("root")->children([ Tags::Span('main caption')->className("caption"), Tags::A('http://example.com', 'main link')->className("link") ]); echo $html->render(); // <div class="root"><span class="caption">main caption</span><a href="http://example.com" class="link">main link</a></div> $html = (new Tags\Tag("custom"))->setAttribute("data", "test"); echo $html->render(); // <custom data="%test"></custom> $html = Tags::Tag("custom")->setAttribute("data", "test"); echo $html->render(); // <custom data="%test"></custom>
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-09