drewm/selecta 问题修复 & 功能扩展

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

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

drewm/selecta

最新稳定版本:v1.0.4

Composer 安装命令:

composer require drewm/selecta

包简介

关键字:

README 文档

README

Build Status Scrutinizer Code Quality

Use a CSS selector to wrap your content with HTML tags.

echo Selecta::wrap('h1.welcome', 'Hello, world');

will output:

<h1 class="welcome">Hello, world</h1>

Why?

Sometimes you need to output a quick bit of HTML at a point where it's really inconvenient to use a full template. Creating strings of HTML in your code is horrible, so this something a bit more humane.

Usage

Currently supports IDs, classes and attribute selectors.

Class names

echo Selecta::wrap('ul.list li', 'So listy');

will output:

<ul class="list"><li>So listy</li></ul>

IDs

echo Selecta::wrap('div#contact', 'Call me');

will output:

<div id="contact">Call me</div>

Attribute and Pseudo-class selectors

echo Selecta::build('input[type=radio][name=color][value=blue]:checked');

will output:

<input type="radio" name="color" value="blue" checked>

Currently supports :checked and :disabled pseudo-classes.

Mix it up

All these can be combined and stacked:

echo Selecta::build('form#contact div.field input[type=text][required]');

will output (indented for clarity):

<form id="contact">
	<div class="field">
		<input type="text" required>
	</div>
</form>

Methods

The following methods are available:

Selecta::wrap(selector, contents) will wrap the contents with the tags created by the selector.

Selecta::open(selector) will open the tags created by the selector.

Selecta::close(selector) will close the tags created by the selector. Note that the order of tags is reversed - you can use the same selector string with open() and close() to get valid tag pairs.

Selecta::build(selector, contents, open, close) will do everything - build the tags, optionally wrap the contents, optionally open and optionally close the tags.

Opening and closing

Don't have a template to hand but need to output some structural markup?

echo Selecta::open('section.sidebar div');
echo $CMS->display_all_my_weird_sidebar_junk();
echo Selecta::close('section div');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-24