Tina4 PHP HTML Shape Language

v2.0.2 2021-07-21 10:35 UTC

This package is auto-updated.

Last update: 2022-05-21 12:21:04 UTC


HTML Language called Shape where you write code to make HTML


composer require tina4stack/tina4php-shape

Basic usage

Each HTML tag has an underscore prefix, <p> tag would be _p()

Normal Tag

echo _p("Hello"); //<p>Hello</p>

Tag with Attributes

echo _div(["class" => "form-group"], "Testing"); //<div class="form-group">Testing</div>

Nesting of tags

Some things become easier to code due to nesting, think of un ordered lists or select tags.

$lis = [];

$lis[] = _li("One");
$lis[] = _li("Two");

$ul = _ul ($lis);

$options = [];

$options[] = _option("One");
$options[] = _option("Two");

$select = _select (["name" => "choose"], $options);

Finding a tag by id

Sometimes you want to manipulate a tag's content, so we find it based on the id attribute.

$tag = $html->byId("someId");

Set the html of a tag

$tag->html(_p("Changed HTML"));


require_once "vendor/autoload.php";

//Start some HTML

$lis = [];

$lis[] = _li("One");
$lis[] = _li("Two");

$ul = _ul ($lis);

$html = _shape(
    _html(["lang" => "en"],
        _h1(["id" => "someId"],"Hello World! H1"),
        _h2("Hello World! H2"),
        $a = _h3("Hello World! H3"),
        _h4("Hello World! H4"),
        _h5("Hello World! H5"),

$a->html(_b(["style" => "color: red"],"Hello"));


echo $html;

You should see something like this