Recommend this page to a friend! |
Classes of Jorge Castro | BladeOneHtml | README.md | Download |
|
DownloadBladeOneHtmlIt 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:
Usage
> composer require eftec/bladeonehtml
$blade=new myBlade(); ![](docs\img1.jpg) Template basicThis library adds a new set of tags for the template. The tags uses named arguments, so it is easily configurable. > @<tag>(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 | Argument | Description | example | | -------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | text | It adds a content between the tags. The inner value is always un-quoted. | @tag(text="hello") -> < tag>hello< /tag> | | pre | It adds a content before the tag | @tag(pre="hello") -> hello< tag>< /tag> | | post | It adds a content after the tag | @tag(post="hello") -> < tag>< /tag>hello | | between | It adds a content between the tags (it works similar than text) | @tag(between="hello") -> < tag>hello< /tag> | | value | Usually it works as the normal "value" of html but it also could works differently (in @textarea works like text) | @tag(value="hello") -> < tag value="hello">< /tag> | | values | Some components needs a list of object/arrays. This argument is used to sets the list of values | @tag(values=$countries) | | alias | Some 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)<br />@tag($values=$countries ) it asumes alias=$countriesRow | | optgroup | The tag @select could list grouped elements. This argument is used to set the grouping | @tag($values=$countries alias=$country @optgroup=$country->continent) | Let's say the next example
It is rendered as
If the tag uses a variable of function, then this view
Is converted into
The method $this->e is used to escape the method. > Note: This library allows any tag, even custom tags (but only if they don't enter in conflict with the special tags, see table) > > @input(value="hello world" type="text" mycustomtag="hi" ) > > Is converted into > > <input value="hello world" type="text" mycustomtag="hi" /> Template usageinputIt shows a input html. Basic example:
![](docs/input_label.jpg) labelIt shows a label html
![](docs/input_label.jpg) imageIt shows an image
![](docs/image.jpg) selectIt shows a select (dropdown list) html object Example:
> Note: items requires to set arguments ![](docs/select.jpg) itemIt is an utilitarian tag used inside some tags. This behave depending of their parent tag. It adds a simple line/row to the parent object. Example:
It renders
itemsIt is an utilitarian tag used inside some tags. This behave depending of their parent tag. It adds a multiples lines/rows to the parent object using the tag values > Note: This tag requires some arguments: > > the parent(or this tag) requires the tagvalues* > the parent requires the tagvalue* It indicates the current selection (if any) > the parent(or this tag) requires the tagalias* If alias is missing the it uses the name of values + "Row", i.e. values=product -> alias= productRow > the parent(or this tag) requires the tagid* > * The rendered "id" will be generated using this id+"_"+"id of the row". i.e. id="idproduct" => idproduct_0, idproduct_1 > * Why? It is because the id must be unique (html specs) Example, if $countries is a list of objects then :
If $countries is a list of arrays then:
Inside the tag items, you could use the next variables | variable (where values is the variable used) | Specification | | -------------------------------------------------------- | ------------------------------------------------------------ | | $valuesOptGroup | It stores the current optgroup (if any). Example: $productOptGroup | | $valuesKey | It indicates the current key of the current row. Example: $productKey | | $alias (if not alias is set then it uses $valuesRow) | The current row of the variable. Example: $productRow | optgroupIt starts an optional group (select) Example:
> Note: this tag must be ended with the tag @endoptgroup ![](docs/optgroup.jpg) checkboxIt adds a single checkbox Example:
![](docs/checkbox.jpg) radioIt adds a single radio button Example:
![](docs/radio.jpg) textareaIt draws a text area. Example:
![](docs/textarea.jpg) buttonIt draws a button Example:
![](docs/button.jpg) linkIt adds an hyperlink Example:
![](docs/link.jpg) checkboxesIt shows a list of checkboxes
![](docs/checkbox.jpg) radiosIt shows a list of radio buttons
![](docs/radio.jpg) fileIt generates a file input value
> Note: it also renders a hidden file with name "name"+"_file" with the original value ![](docs/file.jpg) ulIt generates an unsorted list
![](docs/ul.jpg) olIt generates a sorted list
![](docs/ol.jpg) tableIt renders a table
![](docs/table.jpg) tableheadIt renders the header of the table (optional). Each cell added inside it, is rendered as "th" html tag tablebodyIt renders the body of the table (optional). Each cells added inside it, is rendered as "td" html tag tablefooterIt renders the footer of the table (optional). Each cell added inside it, is rendered as "th" html tag tablerowsIt generates a row inside the body cellsIt renders a cell inside the tablehead,tablebody (tablerows) or tablefooter Version history1.0 2020-04-20 First version |