PHPackages                             eftec/bladeonehtml - 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. eftec/bladeonehtml

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

eftec/bladeonehtml
==================

The standalone version Blade Template Engine from Laravel in a single php file

2.5(1y ago)1018.1k↓31.4%3[1 PRs](https://github.com/EFTEC/BladeOneHtml/pulls)5MITPHPPHP &gt;=7.4

Since Apr 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/EFTEC/BladeOneHtml)[ Packagist](https://packagist.org/packages/eftec/bladeonehtml)[ Docs](https://github.com/EFTEC/BladeOneHtml)[ RSS](/packages/eftec-bladeonehtml/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (19)Used By (5)

BladeOneHtml
============

[](#bladeonehtml)

It is a PHP library that allows to create forms (view) easily, cleanly and without killing the performance. It uses the library BladeOne to renders the view. This library only uses a single dependency, one file and nothing more.

This library works in two ways:

- It compiles a script (our view that use our tags), in a native PHP code.
- And the next read, if the script exists, then it uses it (instead of re-compiling). And since the script is native code, then it is exactly like to work in vanilla-php, but it is way easy to write and to maintenance.

[![Packagist](https://camo.githubusercontent.com/5f41c5298b363667ba8af51071708fc163e96f58f2731008b99caf276827718f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f65667465632f626c6164656f6e6568746d6c2e737667)](https://packagist.org/packages/eftec/bladeonehtml)[![Total Downloads](https://camo.githubusercontent.com/f653306574047205a08c20e7bbbff6496e5f3939102431527e04f0e56d3c5e9a/68747470733a2f2f706f7365722e707567782e6f72672f65667465632f626c6164656f6e6568746d6c2f646f776e6c6f616473)](https://packagist.org/packages/eftec/bladeonehtml)![Maintenance](https://camo.githubusercontent.com/0c8f829897840ac35cb3daf181a719612c0f64c0ed5fca3c7b90ed7591169162/68747470733a2f2f696d672e736869656c64732e696f2f6d61696e74656e616e63652f7965732f323032352e737667)![composer](https://camo.githubusercontent.com/7a6cce75e3353cd615b111f2f4ff50dec30cf814dddb88b2613f656cec298330/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d706f7365722d253345322e302d626c75652e737667)![php](https://camo.githubusercontent.com/59558613d05bebac3748d4f75f0c94435dec5fb11d059b448c2d172e25d82120/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e342d677265656e2e737667)![php](https://camo.githubusercontent.com/5cd91a78fb469ca20b235b6951fb6dd77bda78ac4633eb432e93699bcb141589/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e342d677265656e2e737667)![CocoaPods](https://camo.githubusercontent.com/e53b5646f39eae4d9fa02894b59890214fe71a91cb384a9bf491afed4a86ec2e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d37312532352d79656c6c6f772e737667)

- [BladeOneHtml](#bladeonehtml)
    - [Usage](#usage)
    - [Template basic](#template-basic)
    - [Template usage](#template-usage)
        - [input](#input)
        - [hidden](#hidden)
        - [label](#label)
        - [image](#image)
        - [select](#select)
        - [item](#item)
        - [items](#items)
        - [optgroup](#optgroup)
        - [checkbox](#checkbox)
        - [radio](#radio)
        - [textarea](#textarea)
        - [button](#button)
        - [link](#link)
        - [checkboxes](#checkboxes)
        - [radios](#radios)
        - [file](#file)
        - [ul](#ul)
        - [ol](#ol)
        - [pagination](#pagination)
        - [table](#table)
            - [tablehead](#tablehead)
            - [tablebody](#tablebody)
            - [tablefooter](#tablefooter)
            - [tablerows](#tablerows)
            - [cells](#cells)
        - [cssbox](#cssbox)
            - [How to add a new css into the cssbox?](#how-to-add-a-new-css-into-the-cssbox)
        - [jsbox](#jsbox)
            - [How to add a new JavaScript into the cssbox?](#how-to-add-a-new-javascript-into-the-cssbox)
        - [jscodebox](#jscodebox)
    - [Template Customization](#template-customization)
        - [Set a default class](#set-a-default-class)
        - [Set a custom pattern](#set-a-custom-pattern)
            - [Pattern-Variables inside the code](#pattern-variables-inside-the-code)
            - [Custom attribute](#custom-attribute)
    - [Methods](#methods)
        - [useBootstrap5](#usebootstrap5)
            - [Note: If we want to use the css box, then we need to add to our view the next code](#note-if-we-want-to-use-the-css-box-then-we-need-to-add-to-our-view-the-next-code)
        - [useBootstrap4](#usebootstrap4)
            - [Note: If we want to use the css box, then we need to add to our view the next code](#note-if-we-want-to-use-the-css-box-then-we-need-to-add-to-our-view-the-next-code-1)
        - [useBootstrap3](#usebootstrap3)
        - [addCss](#addcss)
        - [addJS](#addjs)
        - [addJSCode](#addjscode)
    - [Public Fields](#public-fields)
        - [$pattern](#pattern)
        - [$defaultClass](#defaultclass)
        - [$customAttr](#customattr)
    - [Creating a new pattern](#creating-a-new-pattern)
        - [1- Adding a new pattern](#1--adding-a-new-pattern)
        - [2- Creating a new method](#2--creating-a-new-method)
        - [3- Creating a new parent Method (container method)](#3--creating-a-new-parent-method-container-method)
        - [4- Advanced](#4--advanced-)
    - [Version history](#version-history)

Usage
-----

[](#usage)

1. This library requires eftec/bladeone. You could install via Composer in the root folder of your project as

> composer require eftec/bladeonehtml

2. And you should extend the class as follows (BladeOneHtml is a Trait)

```
include "vendor/autoload.php";

use eftec\bladeone\BladeOne;
use eftec\bladeonehtml\BladeOneHtml;

class myBlade extends  BladeOne {
    use BladeOneHtml;
}

$blade=new myBlade();

// for our example:
$myvalue=@$_REQUEST['myform'];
echo $blade->run("exampleview", ['myvalue'=>$myvalue]);
```

3. Create a folders called 📁 "\\views" and 📁 "\\compiles"
4. Inside views, creates the next file 📄 "\\views\\exampleview.blade.php"

```

    @form()
        @input(type="text" name="myform" value=$myvalue)
        @button(type="submit" value="Send")
    @endform()

```

$blade=new myBlade();

[![](docs/img1.jpg)](docs/img1.jpg)

Template basic
--------------

[](#template-basic)

This library adds a new set of tags for the template. The tags uses named arguments, so it is easily configurable.

> @&lt;tag&gt;(argument1="value" argument2='value' argument3=value argument4=$variable argument5=function(), argument6="aaa $aaa")

This library uses the native html arguments but some arguments are special

ArgumentDescriptionexampletextIt adds a content between the tags. **The inner value is always un-quoted.**@tag(text="hello") -&gt; &lt;tag&gt;hello&lt;/tag&gt;preIt adds a content before the tag@tag(pre="hello") -&gt; hello&lt;tag&gt;&lt;/tag&gt;postIt adds a content after the tag@tag(post="hello") -&gt; &lt;tag&gt;&lt;/tag&gt;hellobetweenIt adds a content between the tags (it works similar than text)@tag(between="hello") -&gt; &lt;tag&gt;hello&lt;/tag&gt;valueUsually it works as the normal "**value**" of html but it also could works differently (in @textarea works like **text**)@tag(value="hello") -&gt; &lt; tag value="hello"&gt;&lt;/tag&gt;valuesSome components needs a list of object/arrays. This argument is used to sets the list of values@tag(values=$countries)aliasSome components needs or use a list of object/array. This argument is to reference any row inside the list. If **values** is set and **alias** is missing, then it creates a new alias called values+"Row".@tag($values=$countries alias=$country)
@tag($values=$countries ) **it asumes alias=$countriesRow**optgroupThe tag @select could list grouped elements. This argument is used to set the grouping@tag($values=$countries alias=$country @optgroup=$country-&gt;continent)Let's say the next example

```
@input(value="hello world" type="text" )

```

It is rendered as

```

```

If the tag uses a variable of function, then this view

```
@input(value=$hello type="text" )

```

Is converted into

```
