2017 © Pedro Peláez
 

library selecta

image

drewm/selecta

  • Sunday, November 6, 2016
  • by drewm
  • Repository
  • 2 Watchers
  • 15 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Selecta: super-light casual templating using CSS selectors

Build Status Scrutinizer Code Quality, (*1)

Use a CSS selector to wrap your content with HTML tags., (*2)

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

will output:, (*3)

<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., (*4)

Usage

Currently supports IDs, classes and attribute selectors., (*5)

Class names

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

will output:, (*6)

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

IDs

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

will output:, (*7)

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

Attribute and Pseudo-class selectors

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

will output:, (*8)

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

Currently supports :checked and :disabled pseudo-classes., (*9)

Mix it up

All these can be combined and stacked:, (*10)

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

will output (indented for clarity):, (*11)

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

Methods

The following methods are available:, (*12)

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

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

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., (*15)

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

Opening and closing

Don't have a template to hand but need to output some structural markup?, (*17)

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

The Versions

06/11 2016

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

selector

06/11 2016

v1.0.4

1.0.4.0

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

selector

03/11 2016

v1.0.3

1.0.3.0

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

selector

30/06 2016

v1.0.2

1.0.2.0

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

selector

06/05 2016

v1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

selector

26/06 2015

v1.0

1.0.0.0

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

selector