PHPackages                             zendx/viewautoescape - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. zendx/viewautoescape

ActiveLibrary[Templating &amp; Views](/categories/templating)

zendx/viewautoescape
====================

Zend Framework 1 auto escaping

1.5.1(10y ago)215.3k1BSD-3-ClausePHPPHP &gt;=5.2.4

Since Sep 23Pushed 10y ago2 watchersCompare

[ Source](https://github.com/jensklose/ZendX_View_Autoescaping)[ Packagist](https://packagist.org/packages/zendx/viewautoescape)[ Docs](https://github.com/jensklose/ZendX_View_Autoescaping)[ RSS](/packages/zendx-viewautoescape/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (2)Versions (8)Used By (0)

ZendX\_View\_Autoescaping
=========================

[](#zendx_view_autoescaping)

This project provides you a ViewRenderer with auto escaping of all assigned view variables. It also prevents you to use object variables within view skripts to call methods.

See the examples and tests to understand the facade concept.

[![Build Status](https://camo.githubusercontent.com/521813d782ed17f2ef1a9423944f0e91c7dc5c1a674e2ea5276ccd5b9f435d67/68747470733a2f2f7472617669732d63692e6f72672f6a656e736b6c6f73652f5a656e64585f566965775f4175746f6573636170696e672e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/jensklose/ZendX_View_Autoescaping)

Requirements
------------

[](#requirements)

- Zend Framework 1.X
- PHP 5.2.x (PHPUnit 3.6 requires PHP 5.2.7 or later)
- PHPUnit &gt;= 3.5 (for testing and development)

Installation
------------

[](#installation)

### Composer

[](#composer)

```
...
"require": {
    "zendx/viewautoescape": "~1.5",
}

```

### Download

[](#download)

Copy the sources to your project library path and add the ZendX namespace to project autoloader.

```
autoloaderNamespaces[] = "ZendX_"

```

Configuration
-------------

[](#configuration)

Init the view in your bootstrap.php

```
protected function _initView()
{
    $resources = $this->getOption('resources');
    $options = array();
    if (isset($resources['view'])) {
        $options = $resources['view'];
    }
    $view = new ZendX_View_Autoescape($options);

    if (isset($options['doctype'])) {
        $view->doctype()->setDoctype(strtoupper($options['doctype']));
        if (isset($options['charset']) && $view->doctype()->isHtml5()) {
            $view->headMeta()->setCharset($options['charset']);
        }
    }
    if (isset($options['contentType'])) {
        $view->headMeta()->appendHttpEquiv('Content-Type', $options['contentType']);
    }

    $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
    $viewRenderer->setView($view);
    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
    return $view;
}

```

Examples
--------

[](#examples)

Controller

```
public function indexAction()
{
    $this->view->productClass = 'simpleString';
    $this->view->products = array(
        'make' => array(
            'name' => 'Hacking Session',
            'price' => 672.45
    );
}

```

View script

```
