定制 hitsi/mezzio-smarty-renderer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hitsi/mezzio-smarty-renderer

Composer 安装命令:

composer require hitsi/mezzio-smarty-renderer

包简介

Smarty integration for Mezzio

README 文档

README

Provides Smarty integration for Mezzio.

Installation

Install this library using composer:

$ composer require hitsi/mezzio-smarty-renderer

Mezzio team recommend using a dependency injection container, and typehint against container-interop. We can recommend the following implementations:

Configuration

You need to include the Hitsi\Mezzio\SmartyRenderer\ConfigProvider in your config/config.php. Optional configuration can be stored in config/autoload/templates.global.php.

'templates' => [
    'extension' => 'file extension used by templates; defaults to tpl',
    'paths' => [
        // namespace / path pairs
    ],
],
'smarty' => [
    'template_dir' => 'default/main templates',
    'cache_dir' => 'path to cached templates',
    'compile_dir' => 'path to compiled templates',
    'config_dir' => 'path to config',
    'assets_url' => 'base URL for assets',
    'assets_version' => 'base version for assets',
    'plugins' => [
        // your own plugins
    ],
    'globals' => [
        // Global variables passed to smarty templates
    ],
    'compile_check' => true, // https://www.smarty.net/docs/en/variable.compile.check.tpl
    'force_compile' => false, // https://www.smarty.net/docs/en/variable.force.compile.tpl
    'caching' => false, // https://www.smarty.net/docs/en/variable.caching.tpl
    'debugging' => false, // https://www.smarty.net/docs/en/variable.debugging.tpl
],

Paths

You can use multiple paths (namespaces) for templates

'templates' => [
    'extension' => 'file extension used by templates; defaults to tpl',
    'paths' => [
        'app' => __DIR__.'/../templates/app',
        'admin' => __DIR__.'/../templates/admin',
        'layout' => __DIR__.'/../templates/layout',
        ...
    ],
],
'smarty' => [
    'template_dir' => __DIR__.'/../templates',
    ...
]

And render them

$this->template->render('app::index', $params);

OR

$this->template->render('app/index.tpl', $params);

In template

{extend file='layout:main.tpl'}

OR short description

{extend 'layout:main.tpl'}

Smarty Plugin

The included Smarty plugin adds support for url generation.

  • path: Render the relative path for a given route and parameters. If there is no route, it returns the current path.

    {#path route='article_show' id='3'}
    Generates: /article/3
  • url: Render the absolute url for a given route and parameters. If there is no route, it returns the current url.

    {url route='article_show' id='3'}
    Generates: http://example.com/article/3
  • absolute_url: Render the absolute url from a given path. If the path is empty, it returns the current url.

    {absolute_url route='path/to/something'}
    Generates: http://example.com/path/to/something
  • asset Render an (optionally versioned) asset url.

    {asset route='path/to/asset/name.ext' version='3'}
    Generates: path/to/asset/name.ext?v=3

    To get the absolute url for an asset:

    {absolute_url route={asset route='path/to/asset/name.ext' version='3'}}
    Generates: http://example.com/path/to/asset/name.ext?v=3

Configuration Plugin

You need to include the Hitsi\Mezzio\SmartyRenderer\Plugins\ConfigProvider in your config/config.php. Optional you can add you own plugin like this.

'factories' => [
    Path\To\YourPlugin::class => Path\To\YourPluginFactory::class,
],
'smarty' => [
    'plugins' => [
        'myplugin' => Path\To\YourPlugin::class,
    ],
],

Then use them

{myplugin param1="test" param2="done"}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2021-09-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固