Download the PHP package html5/fhtml without Composer
On this page you can find all versions of the php package html5/fhtml. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package fhtml
Short Description FHtml Fluent HTML writing
License MIT
Homepage http://leuffen.de
Informations about the package fhtml
FHtml - Fluent HTML
Fluent HTML Generator for PHP7 - Version 0.2 - 2016-08-23 - Written by Matthias Leuffen
Generating correct and secure HTML Code within your PHP-Code causes headache. Using FHtml's fluent speaking Api will save you lots of money you'd otherwise spent on aspirin.
It comes with an @
-attribute-parser for easy and painless writing; you don't
need any quotes ('
or "
) within your quoted strings.
Example? See the Kickstart:
Kickstart - See FHtml in action:
yes - no double quotes needed to generate valid and proper escaped xhtml:
Use the fluent-API to generate structures:
yeah: Your PHP-code is shorter than the raw html! And proper indention is done as well:
Have you ever written a <select>
-box with preselected value? This is the FHtml-way:
Using an IDE (PhpStorm)? FHtml comes with full code-completion on
all layers. Stop typing - just hit CTRL-SPACE
and ENTER
.
Features
- Generates proper escaped XHTML-compliant HTML5 code
- Quick writing without quoted quotes
- Full IDE support (tested on Jetbrains PhpStorm)
- Makes use of PHP7 return / parameter declaration
- Autodetecing multiple APIs compatible to I18n Plugins
- Unit-Tested and CI by TravisCI
Install
FHtml is available as composer-package at packagist.com:
or just add it to your composer.json
:
Hint: Use composer upgrade --prefer-dist
to omit unit-tests and development files
Error Reports
Please report errors, wishes and feedback:
- Github-Page: https://github.com/dermatthes/FHtml
- Report Issues: https://github.com/dermatthes/FHtml/issues
Usage
@-attributes
FHtml parses a single string input on elem()
Method (or any direct tag-method like div()
or span()
) and parses it.
To inject insecure or not properly escaped values from outside, use
the ?
-Placeholder construct:
DON'T DO THAT:
use the auto-escaping array construct with ?
as placeholder and add the raw
values as additional parameter(s):
Inserting a text-node
To insert plain text to an element use the text($text)
- method.
The text in Parameter 1 will be html-escaped.
Will generate:
End an element
You can use the end()
Method to jump back to the parent element.
Jump Marks
You can use the as(<jumpMark>)
Method to define a element you
can jump to from anywhere by using goto(<jumpMark>)
:
The example will append the <p>
element to the <body>
element.
Generating <select>
Options from arrays
Use the options(array $options, string $preselect)
- method to create select-options with preselected
Value on the fly:
Imagine you have some mapping of key-values array for your select-field:
Just set them as first parameter of options()
and the submitted Value
from Post into the second parameter:
will generate:
API Alternatives
These Samples are doing exact the same. Choose the api you like most:
I prefer using the shortest:
Related Projects
If you like FHtml you might be interested in some of my other projects:
- html5/template: An angular-js / phptal implementation of inline-template components
- html5/htmlreader: A fast and stupid HTML5 tokenizer not using libxml. (Stupid === Good; if you've ever tried to parse HTML without having libxml manipulating your elements)
Author
Written 2016 by Matthias Leuffen leuffen.de
License
MIT-License