Skip to content
For designers testing their framework views without the working backend code
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/antonienko/PhpTempPrev
tests/antonienko/tests
.gitignore
LICENSE
README.md
composer.json
phpunit.xml.dist
shippable.yml

README.md

PHP Template Previewer

Build Status

PHP template previewer for designers testing their framework views without the working backend code.

Originally created for a personal project using the Phalcon PHP framework and its templating system Volt.

####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

##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.

##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.

In the "require" section of your composer.json file:

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

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

Specific minor version, API stability

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

If you have any problems with the minimum-stability setting try appending @dev to the version

"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

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.

The variables are separated in three categories: scalars, arrays and objects.

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

##License Information Lincensed under The MIT License (MIT). See the LICENSE file for more details.

You can’t perform that action at this time.