Recommend this page to a friend! |
Download |
Info | Example | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 91 | All time: 9,935 This week: 455 |
Version | License | PHP version | Categories | |||
bladeonehtml 1.0 | GNU Lesser Genera... | 5 | HTML, PHP 5, Cache, Templates |
Description | Author | |
This package can be used to create HTML forms using compiled templates. |
<?php |
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:
> composer require eftec/bladeonehtml
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]);
<body>
@form()
@input(type="text" name="myform" value=$myvalue)
@button(type="submit" value="Send")
@endform()
</body>
$blade=new myBlade();
![](docs\img1.jpg)
This 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
@input(value="hello world" type="text" )
It is rendered as
<input value="hello world" type="text" />
If the tag uses a variable of function, then this view
@input(value=$hello type="text" )
Is converted into
<input value="<?php echo $this->e($hello);?>" type="text" />
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" />
It shows a input html.
Basic example:
@input(id="id1" value="hello world$somevar" type="text" )
![](docs/input_label.jpg)
It shows a label html
@label(for="id1" text="hello world:")
![](docs/input_label.jpg)
It shows an image
@image(src="https://via.placeholder.com/350x150")
![](docs/image.jpg)
It shows a select (dropdown list) html object
Example:
@select(id="aaa" value=$selection values=$countries alias=$country)
@item(value='aaa' text='hello world')
@item(value='aaa' text='hello world')
@item(value='aaa' text='hello world')
@items( id="chkx" value=$country->id text=$country->name)
@endselect
> Note: items requires to set arguments
![](docs/select.jpg)
It 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:
@select()
@item(value='aaa' text='hello world')
@endselect
It renders
<select>
<option value="aaa">hello world</option>
</select>
It 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 :
@select(id="aaa" value=$selection values=$countries alias=$country)
@items( id="chkx" value=$country->id text=$country->name)
@endselect
If $countries is a list of arrays then:
@select(id="aaa" value=$selection values=$countries alias=$country)
@items( id="chkx" value=$country['id'] text=$country['name'])
@endselect
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 |
It starts an optional group (select)
Example:
@select(id="aaa" value=$selection values=$countries alias=$country)
@optgroup(label="group1")
@item(value='aaa' text='hello world')
@item(value='aaa' text='hello world')
@item(value='aaa' text='hello world')
@endoptgroup
@endselect
> Note: this tag must be ended with the tag @endoptgroup
![](docs/optgroup.jpg)
It adds a single checkbox
Example:
@checkbox(id="idsimple" value="1" checked="1" post="it is a selection")
![](docs/checkbox.jpg)
It adds a single radio button
Example:
@radio(id="idsimple" value="1" checked="1" post="it is a selection")
![](docs/radio.jpg)
It draws a text area.
Example:
@textarea(id="aaa" value="3333 3333 aaa3333 ")
![](docs/textarea.jpg)
It draws a button
Example:
@button(value="click me" type="submit" class="test" onclick='alert("ok")')
![](docs/button.jpg)
It adds an hyperlink
Example:
@link(href="https://www.google.cl" text="context")
![](docs/link.jpg)
It shows a list of checkboxes
@checkboxes(id="checkbox1" value=$selection alias=$country)
@item(id="aa1" value='aaa' text='hello world' post="<br>")
@item(id="aa2" value='aaa' text='hello world2' post="<br>")
@items(values=$countries value='id' text='name' post="<br>")
@endcheckboxes
![](docs/checkbox.jpg)
It shows a list of radio buttons
@radios(id="radios1" name="aaa" value=$selection alias=$country)
@item(value='aaa' text='hello world' post="<br>")
@item(value='aaa' text='hello world2' post="<br>")
@items(values=$countries value='id' text='name' post="<br>")
@endradios
![](docs/radio.jpg)
It generates a file input value
@file(name="file" value="123.jpg" post="hello world")
> Note: it also renders a hidden file with name "name"+"_file" with the original value
![](docs/file.jpg)
It generates an unsorted list
@ul(id="aaa" value=$selection values=$countries alias=$country)
@item(value='aaa' text='hello world')
@item(value='aaa' text='hello world')
@item(value='aaa' text='hello world')
@items(value=$country->id text=$country->name)
@endul
![](docs/ul.jpg)
It generates a sorted list
@ol(id="aaa" value=$selection values=$countries alias=$country)
@item(value='aaa' text='hello world')
@item(value='aaa' text='hello world')
@item(value='aaa' text='hello world')
@items(value=$country->id text=$country->name)
@endol
![](docs/ol.jpg)
It renders a table
@table(class="table" values=$countries alias=$country border="1")
@tablehead
@cell(text="id")
@cell(text="cod")
@cell(text="name")
@endtablehead
@tablebody(id='hello world' )
@tablerows(style="background-color:azure")
@cell(text=$country->id style="background-color:orange")
@cell(text=$country->cod )
@cell(text=$country->name)
@endtablerows
@endtablebody
@tablefooter
@cell(text="id" colspan="3")
@endtablefooter
@endtable
![](docs/table.jpg)
It renders the header of the table (optional). Each cell added inside it, is rendered as "th" html tag
It renders the body of the table (optional). Each cells added inside it, is rendered as "td" html tag
It renders the footer of the table (optional). Each cell added inside it, is rendered as "th" html tag
It generates a row inside the body
It renders a cell inside the tablehead,tablebody (tablerows) or tablefooter
1.0 2020-04-20 First version
Files (24) | / | docs |
File | Role | Description |
---|---|---|
button.jpg | Icon | Icon image |
checkbox.jpg | Icon | Icon image |
file.jpg | Icon | Icon image |
image.jpg | Icon | Icon image |
img1.jpg | Icon | Icon image |
input_label.jpg | Icon | Icon image |
link.jpg | Icon | Icon image |
ol.jpg | Icon | Icon image |
optgroup.jpg | Icon | Icon image |
radio.jpg | Icon | Icon image |
select.jpg | Icon | Icon image |
table.jpg | Icon | Icon image |
textarea.jpg | Icon | Icon image |
ul.jpg | Icon | Icon image |
Files (24) | / | examples |
File | Role | Description | ||
---|---|---|---|---|
views (1 file, 1 directory) | ||||
example1.php | Example | Example script | ||
testextension3.php | Example | Example script | ||
testextension3_bs.php | Example | Example script |
Files (24) | / | examples | / | views |
File | Role | Description | ||
---|---|---|---|---|
TestExtension (2 files) | ||||
exampleview.blade.php | Aux. | Auxiliary script |
Files (24) | / | examples | / | views | / | TestExtension |
File | Role | Description |
---|---|---|
helloextensions3.blade.php | Aux. | Auxiliary script |
helloextensions3_bs.blade.php | Aux. | Auxiliary script |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.