northrook/html-element 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

northrook/html-element

Composer 安装命令:

composer require northrook/html-element

包简介

A collection of classes for generating HTML elements and their attributes.

README 文档

README

Generate HTML elements and their attributes.

The motivation behind this package is to provide a simple way to generate HTML elements with sensible defaults, while being more light-weight than the DOMDocument class.

Elements can be nested to create complex HTML structures, but unlike DOMDocument it does not provide a way fully traverse the DOM tree.

This is a deliberate design decision to keep the package lightweight and performant.

Important

This package is still in development.

While it is considered MVP and stable, it may still undergo breaking changes.

Note

Documentation is still being written.

Installation

composer require northrook/html-element

Usage

New elements can be created using the Element class:

namespace Northrook\HTML\Element;

$basic = new Element( content: 'Hello World!' );

echo $basic;
<div>Hello World!</div>

Elements can be nested using the $content parameter. It accepts strings, Elements, and arrays of either.

Important

The Element class does not escape provided $content, so ensure you do so either before passing it, or later down the line.

echo new Element( 'h1', [ 'class' => 'example classes' ], $basic );
<h1 class="example classes">
    <div>Hello World!</div>
</h1>
$button = new Element(
    tag        : 'button',
    attributes : [ 'id' => 'Save Action', 'class' => 'btn icon' ],
    content    : [
        new Element( 'i', content: '<svg ... </svg>' ),
        'Save',
    ]
);

echo $button;
<button id="save-action" type="button" class="btn icon">
    <i>...</i>
    Save
</button>

License

MIT

统计信息

  • 总下载量: 133
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固