PHPackages                             lordsimal/custom-html-elements - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. lordsimal/custom-html-elements

ActiveLibrary[Templating &amp; Views](/categories/templating)

lordsimal/custom-html-elements
==============================

Allows you to create custom HTML elements to render more complex template parts

0.3.0(1y ago)41.9k↓50%MITPHPPHP &gt;=8.1CI passing

Since Oct 13Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/LordSimal/custom-html-elements)[ Packagist](https://packagist.org/packages/lordsimal/custom-html-elements)[ RSS](/packages/lordsimal-custom-html-elements/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (11)Used By (0)

Custom HTML Elements
====================

[](#custom-html-elements)

[![Latest Stable Version](https://camo.githubusercontent.com/98333cc06e7acf95ab1df5518f3861fdda272f038d350177d94642084ef14f6d/68747470733a2f2f706f7365722e707567782e6f72672f6c6f726473696d616c2f637573746f6d2d68746d6c2d656c656d656e74732f76)](https://packagist.org/packages/lordsimal/custom-html-elements) [![Total Downloads](https://camo.githubusercontent.com/ebfbf896adb3de081cf3b41edc81d0d0c2bd04df8313a15832c3a68e37f911bc/68747470733a2f2f706f7365722e707567782e6f72672f6c6f726473696d616c2f637573746f6d2d68746d6c2d656c656d656e74732f646f776e6c6f616473)](https://packagist.org/packages/lordsimal/custom-html-elements) [![Latest Unstable Version](https://camo.githubusercontent.com/eb8b11e1fc9e3f4693f898794f535aafd0df50a6fdab2804b81b5780c3f25e97/68747470733a2f2f706f7365722e707567782e6f72672f6c6f726473696d616c2f637573746f6d2d68746d6c2d656c656d656e74732f762f756e737461626c65)](https://packagist.org/packages/lordsimal/custom-html-elements) [![License](https://camo.githubusercontent.com/9f753037bdbc84a92a4f90bec5eef74cc074bd97ac276f2307e30071926bd3a8/68747470733a2f2f706f7365722e707567782e6f72672f6c6f726473696d616c2f637573746f6d2d68746d6c2d656c656d656e74732f6c6963656e7365)](https://packagist.org/packages/lordsimal/custom-html-elements) [![PHP Version Require](https://camo.githubusercontent.com/22f1a08ad7af2450f1bbba8e04d4a153e1eac6937b99d8ef92e4829695c482fb/68747470733a2f2f706f7365722e707567782e6f72672f6c6f726473696d616c2f637573746f6d2d68746d6c2d656c656d656e74732f726571756972652f706870)](https://packagist.org/packages/lordsimal/custom-html-elements)[![codecov](https://camo.githubusercontent.com/8a111d8eec27bb8f1f6217a61bbe179137974a75d5ce9face4091d9891518cd3/68747470733a2f2f636f6465636f762e696f2f67682f4c6f726453696d616c2f637573746f6d2d68746d6c2d656c656d656e74732f67726170682f62616467652e7376673f746f6b656e3d644d6f31344b6a6e6850)](https://codecov.io/gh/LordSimal/custom-html-elements)

Allows you to create custom HTML elements to render more complex template parts with a simpler HTML representation

Requirements
------------

[](#requirements)

- PHP 8.1+

Installation
------------

[](#installation)

```
composer require lordsimal/custom-html-elements
```

Usage
-----

[](#usage)

This is an example representation of a custom HTML element you want to use:

```

```

So this would appear in a HTML output like this:

```
>

    Example Page

```

To render this custom HTML element you need to do this:

```
$htmlOutput = ''; // This variable represents what is shown above
$engine = new \LordSimal\CustomHtmlElements\TagEngine::getInstance([
    'tag_directories' => [
        __DIR__.DIRECTORY_SEPARATOR.'Tags'.DIRECTORY_SEPARATOR,
        __DIR__.DIRECTORY_SEPARATOR.'OtherTagsFolder'.DIRECTORY_SEPARATOR,
    ],
]);
echo $engine->parse($htmlOutput);
```

The element logic can be placed in e.g. `Tags/Youtube.php` or `OtherTagsFolder/Youtube.php`:

```
