2017 © Pedro Peláez
 

library phalcon-view-stringable

A Phalcon 2 View library for rendering string templates

image

rootwork/phalcon-view-stringable

A Phalcon 2 View library for rendering string templates

  • Monday, May 2, 2016
  • by rootwork
  • Repository
  • 3 Watchers
  • 1 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

phalcon-view-stringable

Phalcon view class that adds string rendering ability for Phalcon 2., (*1)

Installation

Install composer in a common location or in your project:, (*2)

curl -s http://getcomposer.org/installer | php

Create the composer.json file as follows:, (*3)

{
    "require": {
        "rootwork/phalcon-view-stringable": "dev-master"
    }
}

Run the composer installer:, (*4)

php composer.phar install

Usage

Loading the view service

// app/config/services.php
use Rootwork\Phalcon\Mvc\View\Stringable as View;

$di->setShared('view', function () use ($config) {
    $view = new View();
    $view->setViewsDir(APP_PATH . '/app/views/');
    $view->setOptions([
        'stringCompilePath' => APP_PATH . '/app/views/string-compile',
        'stringCompileExt'  => '.phtml',
    ]);
    $view->registerEngines([
        'string'    => 'Phalcon\Mvc\View\Engine\Volt',
        '.phtml'    => 'Phalcon\Mvc\View\Engine\Php',
    ]);

    return $view;
});

Rendering string templates

// In controller, model, or anywhere Phalcon Di is available
$view       = $this->getDI()->getShared('view');
$template   = "The quick {{ color }} {{ animal }} jumps over the
               lazy {{ pet }}.";

$view->color    = 'brown';
$view->animal   = 'fox';
$view->pet      = 'dog';

// Simple, immediate rendering
echo $view->renderString($template);

// Hierarchical rendering
$view

The Versions

02/05 2016

dev-master

9999999-dev https://github.com/rootworkit/phalcon-view-stringable

A Phalcon 2 View library for rendering string templates

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4
  • ext-phalcon >=2.0.4

 

The Development Requires

by Mike Soule

view phalcon rootwork render string