A simple template system write once run everywhere!

2.0.0 2024-06-16 22:32 UTC

This package is auto-updated.

Last update: 2025-06-19 15:59:26 UTC


README

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