cesarv/views 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cesarv/views

最新稳定版本:v1.0.0

Composer 安装命令:

composer require cesarv/views

包简介

Simple View Renderer

关键字:

README 文档

README

A simple view renderer - will read a .phtml file from the directory passed to the views.dir option, bind variables to it, and return the content as a string.

NO HEAVY TEMPLATE ENGINE! - PHP does templating on it's own, remember?

Options

The following options are avaliable during object construction:

Option Description Required
views.dir Root path of your views directory. Yes

Usage

Consider the following directory structure:

app/
├── index.php
├── vendor
│   └── autoload.php
└── views
    └── Hello.phtml

Hello.phtml contains the following:

<!doctype html>
<html>
    <head>
        <title>Hello</title>
    </head>
    <body>
        <p>Hello <?= $name ?></p>
    </body>
</html>

This is how we render our view from index.php:

<?php require 'vendor/autoload.php';

$views = new \CesarV\Views\View(array(
    'views.dir' => __DIR__ . '/views'
));

echo $views->render('hello', array('name' => 'Cesar'));

Notice that array('name' => 'Cesar') became $name in Hello.phtml?

统计信息

  • 总下载量: 68
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-31