silassare / otpl
A simple template system write once run everywhere!
1.1.9
2021-03-28 11:14 UTC
Requires
- php: >=5.6.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-04-14 17:46:12 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" />