承接 media32/slim-view-plates 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

media32/slim-view-plates

最新稳定版本:3.0

Composer 安装命令:

composer require media32/slim-view-plates

包简介

A custom Slim framework view for the Plates template system.

README 文档

README

This library provides a custom view for the Slim Framework to support the Plates template engine.

Usage

Add the provider to your composer.json file:

{
    "require": {
        "media32/slim-view-plates": "3.*"
    }
}

Enable it in your application

<?php

$view = new \Media32\Slim\View\Plates();

$app = new \Slim\Slim(array(
    'view' => $view
));

Configuration

Template File Extension

Set $view->fileExtension to the file extension used for all templates.

By default Plates expects the extension to be .php.

Templates Path

Set $view->templatesPath to the location of the templates.

By default Slim-View-Plates will use the Slim templates.path configuration value. This setting allows you to override that value for only the Plates templates.

Templates Folder

Add to the $view->templatesFolders array, where the key is the name of the folder and the value is the path.

Extension

You can access Slim's URL functions inside templates by hooking up the view extension:

$view->parserExtensions = array(
    new \Media32\Slim\View\PlatesExtension()
);

URL

Inside your Plates template you would write:

<?= $this->slim()->urlFor('hello', array('name' => 'Josh', 'age' => '19')); ?>

You can easily pass variables that are objects or arrays by doing:

<a href="<?= $this->slim()->urlFor('hello', array('name' => $person->name, 'age' => $person->age)) ?>">Hello <?= $name; ?></a>

If you need to specify the appname for the getInstance method in the urlFor functions, set it as the third parameter of the function in your template:

<a href="<?= $this->slim()->urlFor('hello', array('name' => $person->name, 'age' => $person->age), 'admin') ?>">Hello <?= $name; ?></a>

Site URL

Inside your Plates template you would write:

<?= $this->slim()->siteUrl('/about/me'); ?>

Base URL

Inside your Plates template you would write:

<?= $this->slim()->baseUrl(); ?>

Slim Instance

Inside your plates template you would write:

<? $this->slim()->getInstance('appname'); ?>

Advanced Usage

To access the Plates engine object for further customization, including loading extensions, call $view->getInstance().

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-09