tutida/altair

There is no license information available for the latest version (1.0.1) of this package.

Auto converting special characters of variables to HTML entities

Maintainers

Details

github.com/tutida/Altair

Source

Issues

Installs: 54 923

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 3

Forks: 5

Open Issues: 1

Type:cakephp-plugin

1.0.1 2018-09-03 02:39 UTC

This package is auto-updated.

Last update: 2024-03-28 11:47:43 UTC


README

Auto converting special characters of variables to HTML entities

Requirements

  • PHP >=5.4.16
  • CakePHP >= ~3.0

Usage

<?php
    class AppController extends Controller
    {

        public function initialize()
        {
            $this->loadComponent('Altair.Altair');
        }
        ...
    }

By doing above, You do not have to write the following(h()) every time.

<?= h($variable); ?>

If you do not want to escape $object, use $object->escape property.

<?php
    class UsersController extends AppController
    {

        public function add()
        {
            $user = $this->Users->newEntity();
            ...
            $user->escape = false;
            $this->set('user', $user);
        }
        ...
    }

If you do not want to escape in the action, use $this->Altair->escape() method.

<?php
    class UsersController extends AppController
    {

        public function add()
        {
            $user = $this->Users->newEntity();
            ...
            // Not escape $viewVars in this action.
            $this->Altair->escape(false);
            $this->set('user', $user);
        }
        ...
    }