phore / html
Fluent HTML Template api
Installs: 4 043
Dependents: 3
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >7.0
- ext-pcre: *
Requires (Dev)
- erusev/parsedown-extra: ^0.7
- phpunit/phpunit: *
- psr/http-message: ^1.0
Suggests
- erusev/parsedown-extra: required to use markdown() methods
README
- Fluent API for creating HTML Elements
- Create, alter, render
Basic example
// Create a div element: $elem = fhtml("div @id=main @class=website"); // Append a <div id=content> to the $elem[] = [ "div @id=content" => "Some Content" ]; // Append paragraph to content div: $elem["?#content"][] = ["p" => "Some escaped content"]; // Render full page including html-header echo $elem->renderPage();
will output:
<div id="main" class="website"> <div id="content"> Some Content <p>Some escaped content</p> </div> </div>
Creating html structures
$doc = fhtml("div @id=name2 @class=bordered");
$doc->alter();
Rendering Templates
Appending to Templates
Use the array append syntax ($template[] =
) to append elements to
an existing element:
$t = fhtml();
$t[] = ["@h1" => "Hello World"];