Skip to content

Commit

Permalink
Merge pull request #1 from vdhicts/feature/update-namespace
Browse files Browse the repository at this point in the history
Update namespace
  • Loading branch information
dvdheiden authored May 3, 2018
2 parents 2835e9c + 98e3c3d commit 4b1013c
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 140 deletions.
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# HtmlElement
# Html Element

This package allows you to easily create HTML elements from PHP. It's inspired by
[David Walsh's blogpost](https://davidwalsh.name/create-html-elements-php-htmlelement-class) but further improved.

```$php
use Vdhicts\HtmlElement\HtmlElement;
use Vdhicts\Dicms\Html;
// Create new html element with attribute name
$selectElement = new HtmlElement('select');
$selectElement = new Html\Element('select');
$selectElement->setAttribute('name', 'something');
$selectElement->generate();
// Create new html element with text and attribute
$paragraphElement = new HtmlElement('p', 'text', ['class' => 'center']);
$paragraphElement = new Html\Element('p', 'text', ['class' => 'center']);
```

## Requirements
Expand All @@ -35,7 +35,7 @@ composer require vdhicts/html-element
A new html element can be created with:

```php
$containerElement = new HtmlElement('div');
$containerElement = new Html\Element('div');
$containerElement->setAttribute('class', 'container');
```

Expand All @@ -58,8 +58,8 @@ $containerElement->setAttributes(['class' => 'container', 'role' => 'container']
Or the element could contain another html element:

```php
$colElement = new HtmlElement('div', '', ['class' => 'col-md-6']);
$rowElement = new HtmlElement('div', '', ['class' => 'row']);
$colElement = new Html\Element('div', '', ['class' => 'col-md-6']);
$rowElement = new Html\Element('div', '', ['class' => 'row']);

$rowElement->inject($colElement);
$containerElement->inject($rowElement);
Expand All @@ -77,8 +77,8 @@ value
* `removeAttributes` or `removeAttribute(attribute)` to remove all attributes or just one.
* `removeAttributeValue(attribute, value)` to remove one value from a attribute.
* `getText`, `addText` or `setText` to retrieve, add or set the inner text.
* `inject` to inject a htmlElement into the current htmlElement.
* `generate` generates the htmlElement and returns its string representation.
* `inject` to inject a Element into the current Element.
* `generate` generates the Element and returns its string representation.
* `output` echos the result of `generate`.

## Tests
Expand All @@ -94,6 +94,17 @@ By default a coverage report will be generated in the `build/coverage` folder.
Any contribution is welcome, but it should be fully tested, meet the PSR-2 standard and please create one pull request
per feature. In exchange you will be credited as contributor on this page.

## Security

If you discover any security related issues in this or other packages of Vdhicts, please email [email protected] instead
of using the issue tracker.

## License

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

## About vdhicts

[Van der Heiden ICT services](https://www.vdhicts.nl) is the name of my personal company for which I work as
freelancer. Van der Heiden ICT services develops and implements IT solutions for businesses and educational
institutions.
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"authors": [
{
"name": "Dick van der Heiden",
"email": "[email protected]"
"email": "[email protected]",
"role": "Developer",
"homepage": "https://www.vdhicts.nl"
}
],
"require": {
Expand All @@ -15,6 +17,6 @@
"phpunit/phpunit": "^6.1"
},
"autoload": {
"psr-4": {"Vdhicts\\HtmlElement\\": "src/"}
"psr-4": {"Vdhicts\\Dicms\\Html\\": "src/"}
}
}
Loading

0 comments on commit 4b1013c

Please sign in to comment.