2017 © Pedro Peláez
 

library view

Template engine with auto escaping html entities and with full PHP-native code support

image

zver/view

Template engine with auto escaping html entities and with full PHP-native code support

  • Saturday, April 8, 2017
  • by s4urp8n
  • Repository
  • 1 Watchers
  • 0 Stars
  • 110 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Zver\View Build Status

Template engine with auto escaping html entities and with full PHP-native code support, (*1)

Install

composer require zver/view

Examples

Loading from string

  $html=View::loadFromString('{{ $caption}}<?=$caption2?>   <?=$caption3?>')
                ->set('caption', 1)
                ->set('caption2', 'hello')
                ->set('caption3', 'meet')
                ->render();

Loading from file

  $html=View::loadFromFile($filename)
                ->set('caption', 1)
                ->render();

Autodetect loading (file or string)

  $html=View::load($filenameOrString)
                ->set('caption', 1)
                ->render();

Views directories

You can add directories to search views files, instead of passing absolute filename as argument, (*2)

Last added dir is first to search, (*3)

Absolute paths also works anyway, (*4)

#

   View::addViewsDirectory(dir1);
   View::addViewsDirectory(dir2);
   View::addViewsDirectory(dir3); <--- added last

Example directory structure, (*5)

\dir3
    \view1.php
\dir2
    \dir4
        \view1.php
    \view1.php
    \view2.php
\dir1
    \view1.php
    \view3.php

and load views like this, (*6)

 View::load('view3');          <---- dir1/view3
 View::load('view1');          <---- dir3/view1 because it's added last
 View::load('dir4/view1');     <---- dir4/view1

Escaping HTML entities

You can use escaping syntax in views, (*7)

<div>
    <?=$string1?>
</div>
<div>
    {{$string2}}
</div>

$string1 - will rendered as it is,, (*8)

$string2 - will escape HTML entities,, (*9)

Nested usage

<div>
    <?=View::load($filename1)->render()?>
</div>
<div>
    <?=View::load($filename2)->render()?>
</div>
<div>
    {{$string2}}
</div>

The Versions

08/04 2017

dev-master

9999999-dev

Template engine with auto escaping html entities and with full PHP-native code support

  Sources   Download

The Requires

 

templating view template engine zver

08/04 2017

1.1.1

1.1.1.0

Template engine with auto escaping html entities and with full PHP-native code support

  Sources   Download

The Requires

 

templating view template engine zver

13/02 2017

1.1.0

1.1.0.0

Template engine with auto escaping html entities and with full PHP-native code support

  Sources   Download

The Requires

 

templating view template engine zver

23/06 2016

1.0.1

1.0.1.0

Template engine with auto escaping html entities and with full PHP-native code support

  Sources   Download

The Requires

 

The Development Requires

templating view template engine zver

23/06 2016

1.0.0

1.0.0.0

Template engine with auto escaping html entities and with full PHP-native code support

  Sources   Download

The Development Requires

templating view template engine zver