nepada/template-factory 问题修复 & 功能扩展

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

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

nepada/template-factory

最新稳定版本:v2.8.1

Composer 安装命令:

composer require nepada/template-factory

包简介

Latte powered template factory on steroids.

README 文档

README

Build Status Coverage Status Downloads this Month Latest stable

Package abandoned

This package is considered obsolete and abandoned. Nette and Latte has evolved a lot since the inception of this package. The functionality of this package can now be replaced by a combination of Latte 3 extensions and TemplateFactory::$onCreate callback.

Installation

Via Composer:

$ composer require nepada/template-factory

Register the extension in config.neon:

extensions:
    templateFactory: Nepada\Bridges\TemplateFactoryDI\TemplateFactoryExtension

Usage

Translator autowiring

Who would want to call setTranslator() manually on every template? With this template factory all you need is to define ITranslator service in your configuration and it gets automatically injected into created templates.

Custom Latte filters

Do you need custom Latte filters in templates? Their definition is pretty straightforward:

templateFactory:
    filters:
        doStuff: [@someService, doStuff]

Template parameters

This is the ultimate answer to the question "How do I get parameter / service from DI container into template?"

templateFactory:
    parameters:
        foo: bar
        service: @anotherService
        containerParam: %param%

Template providers

Similarly to parameters, you can also set latte providers:

templateFactory:
    providers:
        foo: bar
        service: @anotherService
        containerParam: %param%

Custom template functions

Similarly to filters, you can also define callbacks for your custom template functions:

templateFactory:
    functions:
        doStuff: [@someService, doStuff]

Configuration from another CompilerExtension

Some extensions may need to install a Latte filter, or inject a parameter / service into template. This can be done in beforeCompile() phase by customizing setup of TemplateConfigurator.

$templateConfigurator = $containerBuilder->getByType(Nepada\TemplateFactory\TemplateConfigurator::class);
$containerBuilder->getDefinition($templateConfigurator)
    ->addSetup('addFilter', ['filterName', $callback])
    ->addSetup('addFunction', ['functionName', $callback])
    ->addSetup('addProvider', ['provider', $value])
    ->addSetup('addParameter', ['parameter', $value])
    ->addSetup('addParameter', ['parameter', '@someService']);

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-02-06