2017 © Pedro Peláez
 

library php-template-previewer

For designers testing their framework views without the working backend code.

image

antonienko/php-template-previewer

For designers testing their framework views without the working backend code.

  • Tuesday, July 14, 2015
  • by antonienko
  • Repository
  • 2 Watchers
  • 1 Stars
  • 1,999 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

PHP Template Previewer

Build Status, (*1)

PHP template previewer for designers testing their framework views without the working backend code., (*2)

Originally created for a personal project using the Phalcon PHP framework and its templating system Volt., (*3)

Disclaimer:

This is my first composer as well as open source project, so if you see anything that needs improving, don't hesitate and tell me. Read my introduction post, (*4)

List of implemented frameworks

  • Phalcon

Extending the framework support

You can make a request for any framework that you want to use this library into, or even better, make a pull request with your own framework strategy. Just implement the IFrameworkStrategy interface. Use the files under the FrameworkStrategies folder as an example., (*5)

What's new

v0.2.0

  • Added Json file support for the variable files

Installation

Composer

This library is available in packagist.org, you can add it to your project via Composer., (*6)

In the "require" section of your composer.json file:, (*7)

Always up to date (bleeding edge, API not guaranteed stable), (*8)

"antonienko/php-template-previewer": "dev-master"

Specific minor version, API stability, (*9)

"antonienko/php-template-previewer": "0.2.*"

If you have any problems with the minimum-stability setting try appending @dev to the version, (*10)

"antonienko/php-template-previewer": "0.2.*@dev"

Sample Usage

Phalcon Framework

DesignController with an action View that gets two parameters: $controller and $view, which are the name of the controller and action view that you want to render. You would call the url like this: http://localhost/designTest/view/controllername/viewname but you are not restricted to use it in this way, (*11)

namespace app\controllers;
use antonienko\PhpTempPrev\FrameworkStrategies\PhalconStrategy;
use antonienko\PhpTempPrev\FileStrategies\IniFileStrategy;
use antonienko\PhpTempPrev\Previewer;

class DesignTestController extends ControllerBase
{
    public function viewAction($controller, $view)
    {
        $view_variables_file = APP_PATH . 'templateHelpers/' . $controller . '/' . $view . '.ini';
        $layout_variables_file = APP_PATH . 'templateHelpers/general.ini';
        $previewer = new Previewer(new PhalconStrategy($this->view));
        $previewer->render("$controller/$view", new IniFileStrategy([$layout_variables_file, $view_variables_file]));
    }
}

Var files

You pass to the render a class implementing IFileStrategy initialized with an array of var files. In case of having the same variable defined in two of the var files, the last one will prevail., (*12)

The variables are separated in three categories: scalars, arrays and objects., (*13)

If you want to get an idea of how the var files work take a look at the test fixtures., (*14)

License Information

Lincensed under The MIT License (MIT). See the LICENSE file for more details., (*15)

The Versions

14/07 2015

dev-master

9999999-dev http://www.antoniohs.com/2015/04/29/php-template-previewer-improving-the-workflow-between-web-designers-and-coders/

For designers testing their framework views without the working backend code.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

framework template preview

30/04 2015

v0.2.0

0.2.0.0

For designers testing their framework views without the working backend code.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

framework template preview

29/04 2015

v0.1.0

0.1.0.0

For designers testing their framework views without the working backend code.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

framework template preview