This is a Conversion library that handles the input from Sir Trevor and converts it to HTML. In the future, the conversion from HTML to the Json input Sir Trevor needs will be implemented too.
- Heading
- Paragraph
- List
- Video
- Quote
- Image
It's easy to add a custom block. Just add a new ConversionType in the Sioen\Types namespace and register it in the ToJsonContect and the ToHtmlContect.
This library package requires PHP 5.3 or later.
Require the library in your composer.json:
run composer require woutersioen/sir-trevor-php
.
Make sure you have require 'vendor/autoload.php';
in the top of your script. If you're using a Framework, this should be ok by default.
// add the composer autoloader to your file
require_once 'vendor/autoload.php';
// Add a use statement to be able to use the class
use Sioen\Converter;
// fetch the data from the post
$sirTrevorInput = $_POST['textarea'];
// create a converter object and handle the input
$converter = new Converter();
$html = $converter->toHtml($sirTrevorInput);
// fetch html from database or wherever you want to fetch it from
$html = '<h2>This is my html</h2>';
// create a converter object and handle the output
$converter = new Converter();
$json = $converter->toJson($html);