2017 © Pedro Peláez
 

library templating

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

image

gelembjuk/templating

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

  • Friday, April 22, 2016
  • by gelembjuk
  • Repository
  • 2 Watchers
  • 1 Stars
  • 54 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Gelembjuk/Templating

Common interface for different PHP templating engines like Smarty, Twig. This package allows to switch between engines witout changes in your PHP code., (*1)

The package was created to be able to migrate to different popular PHP templating engines without need to change my application code. However, it is still needed to modify templates., (*2)

Installation

Using composer: gelembjuk/templating require: {"gelembjuk/templating": "1.*"}, (*3)

Additionally, you have to install a template engine you want to use - smarty/smarty or twig/twig (later i hope to add support of other engines)., (*4)

Configuration

Configuration is done in run time with a constructor options (as hash argument), (*5)

$templateroptions = array(
        'templatepath' => $templatesdir, // directory where templates are stored
        'compiledir' => $compiledir,    // directory to use for compilation temp files. It is needed fro Smarty, but not Twig 
        'usecache' => false,       // don't cache . If true then use cache
        'cachedir' => $cachedir,   // path to cache directory. used if `usecache` is true
        'extension' => 'htm' // our templates files will have htm extension
    );

Usage


require '../vendor/autoload.php'; $templater = new Gelembjuk\Templating\SmartyTemplating(); // $templater = new Gelembjuk\Templating\TwigTemplating(); // init template engine $templater->init($templateroptions); $templater->setVar('firstname',"John"); $templater->setVar('lastname',"Smith"); $templater->setTemplate('homepage'); // fetch page page content $pagecontent = $templater->fetchTemplate(); echo $pagecontent;

File homepage.htm in case of Smarty, (*6)



Hello {$lastname}, {$firstname}

File homepage.htm in case of Twig, (*7)



Hello {{ lastname }}, {{ firstname }}

Author

Roman Gelembjuk (@gelembjuk), (*8)

The Versions

22/04 2016

dev-master

9999999-dev

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

  Sources   Download

MIT

by Roman Gelembjuk

22/04 2016

1.0.7

1.0.7.0

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

  Sources   Download

MIT

by Roman Gelembjuk

12/03 2016

1.0.6

1.0.6.0

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

  Sources   Download

MIT

by Roman Gelembjuk

20/02 2016

1.0.5

1.0.5.0

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

  Sources   Download

MIT

by Roman Gelembjuk

17/12 2015

1.0.4

1.0.4.0

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

  Sources   Download

MIT

by Roman Gelembjuk

14/11 2015

1.0.3

1.0.3.0

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

  Sources   Download

MIT

by Roman Gelembjuk

11/09 2015

1.0.2

1.0.2.0

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

  Sources   Download

MIT

by Roman Gelembjuk

11/09 2015

1.0.1

1.0.1.0

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

  Sources   Download

MIT

by Roman Gelembjuk

28/07 2015

1.0.0

1.0.0.0

Common interface for different PHP templating engines like Smarty,Twig. This package allows to switch between engines witout changes in your PHP code

  Sources   Download

MIT

by Roman Gelembjuk