zver/view
Composer 安装命令:
composer require zver/view
包简介
Template engine with auto escaping html entities and with full PHP-native code support
README 文档
README
Template engine with auto escaping html entities and with full PHP-native code support
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
Last added dir is first to search
Absolute paths also works anyway
View::addViewsDirectory(dir1); View::addViewsDirectory(dir2); View::addViewsDirectory(dir3); <--- added last
Example directory structure
\dir3
\view1.php
\dir2
\dir4
\view1.php
\view1.php
\view2.php
\dir1
\view1.php
\view3.php
and load views like this
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
<div>
<?=$string1?>
</div>
<div>
{{$string2}}
</div>
$string1 - will rendered as it is,
$string2 - will escape HTML entities,
Nested usage
<div>
<?=View::load($filename1)->render()?>
</div>
<div>
<?=View::load($filename2)->render()?>
</div>
<div>
{{$string2}}
</div>
统计信息
- 总下载量: 130
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2016-06-23