2017 © Pedro Peláez
 

package php-html-generator

PHP html generator

image

airmanbzh/php-html-generator

PHP html generator

  • Friday, April 6, 2018
  • by Airmanbzh
  • Repository
  • 7 Watchers
  • 41 Stars
  • 6,599 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 24 Forks
  • 3 Open issues
  • 5 Versions
  • 31 % Grown

The README.md

PHP HTML GENERATOR

Create HTML tags and render them efficiently., (*1)

Build status: * Master Build Status * Dev Build Status, (*2)

Overview

return HtmlTag::createElement();
// returns an empty HtmlTag Container

```php return HtmlTag::createElement('a'); // returns an HtmlTag containing a 'a' tag, (*3)


### Why you should use it - it always generates valid HTML and XHTML code - it makes templates cleaner - it's easy to use and fast to execute ## Render tags ```php echo(HtmlTag::createElement('a'));

or, (*4)

$tag = HtmlTag::createElement('a')
echo( $tag );

Simple tags

echo HtmlTag::createElement('div');

```html , (*5)


```php echo(HtmlTag::createElement('p')->text('some content'));

```html , (*6)

some content, (*7)


### Structured tags ```php echo(HtmlTag::createElement('div')->addElement('a')->text('a text'));

```html , (*8)


```php $container = HtmlTag::createElement('div'); $container->addElement('p')->text('a text'); $container->addElement('a')->text('a link');

```html , (*9)

a text, (*10)

a link
### Attributes

#### Classics attributes (method : 'set')

```php
$tag = HtmlTag::createElement('a')
    ->set('href','./sample.php')
    ->set('id','myID')
    ->text('my link');
echo( $tag );

```html my link, (*11)


#### Shortcut to set an ID attribute (method : 'id') ```php $tag = HtmlTag::createElement('div') ->id('myID'); echo( $tag );

```html , (*12)

my link

#### Class management (method : 'addClass'/'removeClass') ```php $tag = HtmlTag::createElement('div') ->addClass('oneClass') ->text('my content') echo( $tag );

```html , (*13)

my content

```php $tag = HtmlTag::createElement('div') ->addClass('aClass') ->addClass('anothereClass') ->text('my content') echo( $tag );

```html , (*14)

my content

```php $tag = HtmlTag::createElement('div') ->addClass('firstClass') ->addClass('secondClass') ->text('my content') ->removeClass('firstClass'); echo( $tag );

```html , (*15)

my content

### More Text and content are generated according to the order of addition ```php $tag = HtmlTag::createElement('p') ->text('a text') ->addElement('a') ->text('a link');

```html , (*16)

ma texta link, (*17)


To generate content before text, 2 solutions : ```php $tag = HtmlTag::createElement('p') ->addElement('a') ->text('a link') ->getParent() ->text('a text');

or, (*18)

$tag = HtmlTag::createElement('p');
$tag->addElement('a')->text('a link');
$tag->text('a text');
<p><a>a link</a>a text</p>

The Versions

06/04 2018

dev-master

9999999-dev https://github.com/Airmanbzh/php-html-generator

PHP html generator

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php generator html

06/04 2018

v1.0.2

1.0.2.0 https://github.com/Airmanbzh/php-html-generator

PHP html generator

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php generator html

06/04 2018

dev-dev

dev-dev https://github.com/Airmanbzh/php-html-generator

PHP html generator

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php generator html

27/12 2017

v1.0.1

1.0.1.0 https://github.com/Airmanbzh/php-html-generator

PHP html generator

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php generator html

28/10 2016

v1.0.0

1.0.0.0 https://github.com/Airmanbzh/php-html-generator

PHP html generator

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php generator html