2017 © Pedro Peláez
 

library piece

Simple template engine for ItCourses Framework

image

antonkalmykov/piece

Simple template engine for ItCourses Framework

  • Tuesday, February 16, 2016
  • by kalmykovanton
  • Repository
  • 1 Watchers
  • 1 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Piece

Simple template engine component for ITCourses Jazz PHP framework, (*1)

How to use:

First of all, create an array of settings for Piece component:, (*2)

// settings array
$settings = [
    // folder, where you store your view's
    'viewsFolder' => __DIR__ . '/views',
    // file extension, which you use for your
    // template and views files
    'fileExtension' => '.phtml'
];

After that, create an instance of Piece component and pass into it your settings array:, (*3)

use Piece\ViewEngine;
$view = new ViewEngine($settings);

Now, you can run Piece's render() method, which it first argument is name of view and second - array of view's parameters (if any):, (*4)

$view->render('home', ['content'=>'Some content for home page.']);

Supposing our view's files stored in Views folder and template's files in Views/templates folder., (*5)

Views/home.phtml view example:, (*6)

@template('templates/template');



This is view content.

=$content?>, (*7)

In this case, @template('templates/template'); flag tell Piece's render() method where it can find template for this view., (*8)

Views/templates/template.phtml template example:, (*9)

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Home page</title>
</head>
<body>
    @embed;
</body>
</html>

@embed; flag tell Piece's render() method where it must inject view's body., (*10)

You can use any PHP construction and variables, in view's files and template's files. All of they are processed by render() method., (*11)

This method also provides XSS protection., (*12)

The Versions

16/02 2016

dev-master

9999999-dev https://github.com/kalmykovanton/Piece

Simple template engine for ItCourses Framework

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Anton Kalmykov

16/02 2016

v1.1.1

1.1.1.0 https://github.com/kalmykovanton/Piece

Simple template engine for ItCourses Framework

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Anton Kalmykov

16/02 2016

1.1.0

1.1.0.0 https://github.com/kalmykovanton/Piece

Simple template engine for ItCourses Framework

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Anton Kalmykov

04/02 2016

v1.0.0

1.0.0.0 https://github.com/kalmykovanton/Piece

ItCourses Framework Piece Component

  Sources   Download

MIT

The Requires

 

by Anton Kalmykov