定制 brick/html 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

brick/html

最新稳定版本:0.1.1

Composer 安装命令:

composer require brick/html

包简介

HTML 5 generation library

关键字:

README 文档

README

A very simple HTML 5 generation library.

Build Status Coverage Status Latest Stable Version License

Installation

This library is installable via Composer:

composer require brick/html

Requirements

This library requires PHP 7.1 or later.

Project status & release process

This library is still under development.

The current releases are numbered 0.x.y. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), y is incremented.

When a breaking change is introduced, a new 0.x version cycle is always started.

It is therefore safe to lock your project to a given release cycle, such as 0.1.*.

If you need to upgrade to a newer release cycle, check the release history for a list of changes introduced by each further 0.x.0 version.

Introduction

This library contains a single class, Tag, that represents an HTML tag. You construct a Tag using a tag name:

use Brick\Html\Tag;

$div = new Tag('div');

Attributes

You can pass an optional associative array of attributes to the constructor:

$div = new Tag('div', [
    'id' => 'main',
    'class' => 'block',
]);

Or you can set attributes later:

$tag->setAttributes([
    'id' => 'main',
    'class' => 'block',
]);

Or:

$tag->setAttribute('id', 'main')
    ->setAttribute('class', 'block');

You can also remove attributes:

$tag->removeAttribute('id');

Content

You can set the content of a Tag, provided that it's not a void tag such as <br>, <input>, etc. If you try to modify the content of a void tag, you'll get a LogicException.

You can set or append a plain text content:

$tag->setTextContent('Hello, world!');
$tag->appendTextContent("\nWhat's up?");

Or set/append a HTML content:

$tag->setHtmlContent('Hello, <b>world!</b>');
$tag->appendHtmlContent("<br>What's up?");

You can also append another Tag:

$tag->append($otherTag);

You can remove the content of a Tag:

$tag->empty();

You can check if a Tag has an empty content:

$tag->isEmpty(); // boolean

Rendering a tag

You can render a tag by using its render() method, or just by casting it to string:

echo $tag; // will output something like: <div id="main">Hello, world!</div>

Encoding

All texts (attributes, content) are expected to be valid UTF-8.

统计信息

  • 总下载量: 2.43k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固