承接 danjam/slim-mustache-view 相关项目开发

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

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

danjam/slim-mustache-view

最新稳定版本:1.1.2

Composer 安装命令:

composer require danjam/slim-mustache-view

包简介

Simple Slim 3 framework view renderer for mustache templates using Mustache.php

README 文档

README

Build Status Latest Stable Version Coverage Status SensioLabsInsight

Simple Slim 3 framework view renderer for mustache templates using Mustache.php

Install

Via Composer

$ composer require danjam/slim-mustache-view

Usage

// create Slim 3 app
$app = new \Slim\App();

// get the container
$container = $app->getContainer();

// register Mustache view
$container['view'] = function ($container) {
    $view = new \Slim\Views\Mustache();
    
    return $view;
};

// define the route
$app->get('/hello/{name}', function ($request, $response, $args) {
    return $this->view->render($response, 'Hello, {{name}}', [
        'name' => $args['name']
    ]);
});

// run the app
$app->run();

The constructor takes an optional array of Mustache.php options. See the Mustache.php documentation for details.

// register Mustache view
$container['view'] = function () {
    $view = new \Slim\Views\Mustache([
        'cache' => './cache/mustache',
        'loader' => new Mustache_Loader_FilesystemLoader('./views'),
        'partials_loader' => new Mustache_Loader_FilesystemLoader('./views/partials')
    ]);

    return $view;
};

You can also capture raw template contents if needed. This can be useful for rendering inline templates, for example when also using mustache.js

$this->view->getRawTemplate('some-template.html');

Testing

phpunit

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-25