Skip to content

This library simplifies HTML elements rendering.

License

Notifications You must be signed in to change notification settings

PiotrPress/elementor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Elementor

This library simplifies HTML elements rendering.

Installation

$ composer require piotrpress/elementor

Example

require __DIR__ . '/vendor/autoload.php';

use PiotrPress\Elementor;
use PiotrPress\Elementor\Element;
use PiotrPress\Elementor\Attributes;

// Example #1
echo new Elementor( [
    [ 'div',
        [ 'class' => 'main' ],
        [
            [ 'input',
                [
                    'type' => 'submit',
                    'required'
                ]
            ],
            [ 'a',
                [
                    'href' => 'https://piotr.press',
                    'class' => [ 'red', 'border' ]
                ],
                'Click'
            ]
        ]
    ]
] );
// <div class="main"><input type="submit" required /><a href="https://piotr.press" class="red border">Click</a></div>

// Example #2
echo new Element( 'a', [
    'href' => 'https://piotr.press',
    'class' => [ 'red', 'border' ]
], 'Click' );
// <a href="https://piotr.press" class="red border">Click</a>

// Example #3
echo new Element( 'input', [
    'type' => 'submit',
    'required'
] );
// <input type="submit" required />

// Example #4
echo new Attributes( [
    'href' => 'https://piotr.press',
    'class' => [ 'red', 'border' ]
] );
// href="https://piotr.press" class="red border"

Requirements

PHP >= 7.4 version.

License

MIT