定制 bryantebeek/tagger 二次开发

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

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

bryantebeek/tagger

Composer 安装命令:

composer require bryantebeek/tagger

包简介

A beautiful html markup library.

README 文档

README

Composer

Installing Tagger with composer is super easy, just add the following requirement to your composer.json:

"bryantebeek/tagger": "v1.0.*"

Usage

You can start using Tagger by calling the desired tag name as a static method on the Tag class.

Tagger\Tag::div();

Tagger\Tag::img();

Adding content

It is possible to pass the content of a tag right when you initialize it.

Tagger\Tag::div('Hello World!');

Instead of passing the content in directly, content can be set after the tag has already been initialized.

Tagger\Tag::div()->content('Hello World!');

The content of a tag can also be set using an anonymous function.

Tagger\Tag::div(function ($tag) {
    return 'Hello World!';
});

Adding attributes

Attributes can be set in a variety of different ways.

// <div id="main"></div>
Tagger\Tag::div()->id('main');

$tag = Tagger\Tag::div();
$tag->id = 'main';

Please note that some HTML attributes can't be set using dynamic accessors because they contain, for example, a hyphen.

// <div data-title="Hello World!">
Tagger\Tag::div()->setAttribute('data-title', 'Hello World!');

It is also possible to set multiple attributes at the same time.

$attributes = array(
	'id' => 'main',
	'data-title' => 'Hello World!',
);

Tagger\Tag::div()->setAttributes($attributes);

Please note that all ways of setting attributes return the object to allow for chaining.

Rendering a Tag

There are three possible ways to render a tag to HTML.

$tag = Tagger\Tag::div();

// All following lines will output: <div></div>
echo $tag;
echo $tag->render();
echo $tag->open() . $tag->close();

Checking attributes

It is possible to check if a tag has certain attributes.

$tag = Tagger\Tag::div()->id('main')->class('container');

$tag->hasAttribute('id'); // true
$tag->hasAttributes(array('id', 'class')); // true
$tag->hasAttributes(array('class', 'title')); // false

Build Status

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-12-05