doT-php

PHP rendering engine for doT.js (The fastest + concise javascript template engine for nodejs and browsers)

GPL-2.0 License

Downloads
6.4K
Stars
4
Committers
2

doT-php

PHP rendering engine for doT.js (The fastest + concise javascript template engine for nodejs and browsers).

How to use it

// Load the library
require_once('resources/doT-php/doT.php');

// Load the template
$page = file_get_contents('templates/page.html');

// instanciate the object
$template = new doT();

// Compile your templace in a PHP function ($dot)
$dot = $template->template($page);

// the data is simple PHP array
$data = array('title' => 'My custom title');

// Write the HTML
echo $dot($data);

Warning

It's far from complete. I needed it just to provide a server side rendering engine for another project (COPS).

So the code provided works perfectly for the templates of COPS and was never tested elsewhere, doT's unit test were also never tested.

That being said, You can fork, enhance it and send me some pull request, I'll happily merge them.