silassare / otpl-php

A simple & lightweight template system: write once compile everywhere with JavaScript, PHP ...

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OTPL

A simple template system, write once run everywhere with JavaScript (nodejs or in browser ), PHP ...

Your contributions are welcomed

Setup with composer

$ composer require silassare/otpl-php

Use case

Input: your template.otpl file content

<label for="<% $.input.id %>"><% $.label.text %></label>
<input <% @HtmlSetAttr($.input) %> />

Usage: php

<?php

require_once "vendor/autoload.php";

$otpl = new \OTpl\OTpl();
$otpl->parse('template.otpl');
$data = array(
	'label' => array(
		'text' => 'Your password please :',
	),
	'input' => array(
		'id' => 'pass_field',
		'type' => 'password',
		'name' => 'pass'
	)
);

$otpl->runWith($data);

Output

<label for="pass_field">Your password please :</label>
<input type="password" id="pass_field" name="pass" />

About

A simple & lightweight template system: write once compile everywhere with JavaScript, PHP ...

License:MIT License


Languages

Language:PHP 99.6%Language:Shell 0.4%