2017 © Pedro Peláez
 

library tpl

Dead simple PHP template engine

image

playsms/tpl

Dead simple PHP template engine

  • Sunday, August 14, 2016
  • by antonraharja
  • Repository
  • 3 Watchers
  • 3 Stars
  • 12,577 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 6 Versions
  • 4 % Grown

The README.md

README

Dead simple PHP template engine, (*1)

Information Description
Author Anton Raharja
Version 1.0.8
Release date 140422
Last update 210910

Install

Using composer by providing or editing composer.json., (*2)

Minimum composer.json:, (*3)

{
    "require": {
        "playsms/tpl": "1.*"
    }
}

More information about composer can be found at its website https://getcomposer.org, (*4)

This package can also be installed without composer. You can simply include the src/Playsms/Tpl.php., (*5)

Usage example

An example template file the_page.html:, (*6)

<div>
    <p>This is the title: {{ title }}</p>
    <p>This is the content: {{ content }}</p>
    <p>And this is the data: {{ $data }}</p>
    <loop.lines>
    <p style='background-color: {{ lines.hexcode }}'>Color: {{ lines.color }}</p>
    </loop.lines>
</div>

Example PHP file show_page.php using the template file the_page.html:, (*7)

<?php

require 'vendor/autoload.php';

$data = 'THE DATA HERE';

$loops = array(
    'lines' => array(
        array('color' => 'Red',   'hexcode' => '#FF0000'),
        array('color' => 'Green', 'hexcode' => '#00FF00'),
        array('color' => 'Blue',  'hexcode' => '#0000FF'),
    ),
);

$tpl = new \Playsms\Tpl;

$tpl->setTemplate('./templates/test6.html');

$tpl->setVars(array(
    'title' => 'THE TITLE HERE',
    'content' => 'THE CONTENT HERE',
    ))
    ->setLoops($loops)
    ->setInjects(array('data'));

$tpl->compile();

echo $tpl->getCompiled();

After compile() you can get compiled content using getCompiled():, (*8)

<div>                                                                                                                                                        
    <p>This is the title: THE TITLE HERE</p>                                                                                                                 
    <p>This is the content: THE CONTENT HERE</p>                                                                                                             
    <p>And this is the data: THE DATA HERE</p>                                                                                                               

    <p style='background-color: #FF0000'>Color: Red</p>                                                                                                      

    <p style='background-color: #00FF00'>Color: Green</p>                                                                                                    

    <p style='background-color: #0000FF'>Color: Blue</p>                                                                                                     

</div>

For more examples please see examples folder., (*9)

Other documents can be found in docs folder., (*10)

The Versions

14/08 2016

dev-master

9999999-dev http://github.com/antonraharja/tpl

Dead simple PHP template engine

  Sources   Download

MIT

template layout playsms tpl

14/08 2016

1.0.4

1.0.4.0 http://github.com/antonraharja/tpl

Dead simple PHP template engine

  Sources   Download

MIT

template layout playsms tpl

22/04 2014

1.0.3

1.0.3.0 http://github.com/antonraharja/tpl

Dead simple PHP template engine

  Sources   Download

MIT

template layout playsms tpl

21/04 2014

1.0.2

1.0.2.0 http://github.com/antonraharja/tpl

Dead simple PHP template engine

  Sources   Download

MIT

template layout playsms tpl

19/04 2014

1.0.1

1.0.1.0 http://github.com/antonraharja/tpl

Dead simple PHP template engine

  Sources   Download

MIT

template layout tpl

19/04 2014

1.0.0

1.0.0.0 http://github.com/antonraharja/tpl

Dead simple PHP template engine

  Sources   Download

MIT

template layout tpl