1.1.7 • Published 5 years ago

otpl-js v1.1.7

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

OTPL

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

Your contributions are welcomed

NPM

Setup with npm

$ npm install otpl-js

Run Build

$ npm run build

Run Test

$ npm run test:run

Use case

Input: your template.otpl file content

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

Usage: nodejs

var otpl = require('otpl-js');
var data = {
		'label' : {
			'text' : 'Your password please :',
		},
		'input' : {
			'id' : 'pass_field',
			'type' : 'password',
			'name' : 'pass'
		}
	};
//get otpl instance
var o = new otpl();
//parse your template
	o.parse('template.otpl');
//run your templated with your input data 
var output = o.runWith(data);

	console.log(output);

Usage: browser

var data = {
		'label' : {
			'text' : 'Your password please :',
		},
		'input' : {
			'id' : 'pass_field',
			'type' : 'password',
			'name' : 'pass'
		}
	};

//get otpl instance
var o = new OTpl();
//parse your template
	o.parse('template.otpl');
//run your templated with your input data 
var output = o.runWith(data);

	console.log(output);

Usage: 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" />
1.1.7

5 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago