Skip to content

A php converter for Sir Trevor. It converts the Sir Trevor json to Html and vice versa

License

Notifications You must be signed in to change notification settings

ngangchill/sir-trevor-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Sir Trevor JSON to HTML Converter

Build Status Scrutinizer Code Quality SensioLabsInsight

Introduction

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.

Supported Sir Trevor blocks

  • 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.

Requirement

This library package requires PHP 5.3 or later.

Installation

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.

Usage

Overal

// 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;

Conversion to HTML

// fetch the data from the post
$sirTrevorInput = $_POST['textarea'];

// create a converter object and handle the input
$converter = new Converter();
$html = $converter->toHtml($sirTrevorInput);

Conversion to Json

// 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);

About

A php converter for Sir Trevor. It converts the Sir Trevor json to Html and vice versa

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%