bertptrs/marty
Composer 安装命令:
composer require bertptrs/marty
包简介
Smarty view renderer for the Mako framework
README 文档
README
Marty is a simple Smarty view renderer for the Mako framework.
Requirements
Marty has been tested on all current Mako versions. Any other version may work, but has not been tested. Unit tests are run against PHP 7.0 and up. Smarty 3 or 4 is required, but will be pulled in as part of the installation.
Installation
Marty can be added to your Mako project using composer! Just add it to your requirements
{ /* Stuff */ require: { /* Your other requirements */ "bertptrs/marty": "*" } /* The rest of your composer.json*/ }
Usage
Once installed, you will need to add it to your packages list. You do
this by adding it to the "Web" packages. This is located in the file
app/config/application.php.
<?php return [ // … 'packages' => [ // … 'web' => [ 'marty\MartyPackage', ], ], // … ]; ?>
This enables the Smarty View renderer for every view with the ".tpl" file extension.
Configuration
Configuration can be done by changing the marty::smarty configuration.
Just refer to the Mako documentation on package
configuration
for details.
The configuration properties are as follows:
| Configuration property | Type | Description | Default |
|---|---|---|---|
| smarty.templateDir | string | The location to find smarty templates. | Your app/views directory. |
| smarty.compileDir | string | The location to store compiled templates. | A new directory smarty in your app/storage directory. |
| smarty.pluginDirs | string[] | A list of directories to search for smarty plugins. | An empty array. |
Plugins
Marty supports the plugin structure offered by Smarty, and extends it to use the dependency injector offered by the Mako framework.
Plugin dirs can be added to the config. The structure for plugins can be found in the Smarty Documentation. Due to the fact that Mako resolves parameters by name, Smarty plugin parameters should have their names as specified in the documentation. This means that the parameters should be named as follows:
- Template functions:
- parameters should be named
$params - The smarty template should be named
$template
- parameters should be named
- Modifiers:
- The input data should be named
$value - Any other values will be stored in array
$paramsin order.
- The input data should be named
- Block functions:
- Call parameters should be named
$params - The block content should be named
$content - The template reference should be named
$template - The repetition flag should be named
$repeat.
- Call parameters should be named
- Compiler functions:
- Call parameters should be named
$params - The Smarty reference should be named
$smarty
- Call parameters should be named
As an example, we can build a small plugin that uses the I18n module of the framework.
function smarty_modifier_i18n($value, mako\i18n\I18n $i18n) { return $i18n->get($value); }
Then, we can use your plugin like this:
Lets show {'some.translated.text'|i18n}.
Contributing
If there are any features in Smarty that cannot (easily) be used in the current package, or if there are Mako features that are hard to bind to Smarty, feel free to file an issue or a pull request.
Code style and such are ran using GrumPHP. Make sure that your files are in accordance to those rules.
bertptrs/marty 适用场景与选型建议
bertptrs/marty 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.42k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 10 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「template」 「smarty」 「mako」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bertptrs/marty 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bertptrs/marty 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bertptrs/marty 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generate routes based on OpenAPI specifications and OpenAPI specifications from code
A debug toolbar for the Mako Framework
Rewritten Smarty foreach variant that was invented for use in xoops, but nowadays is used in some other PHP based CMS'es
A REPL for the Mako Framework
Mako Framework
Modified Smarty for Rudrax
统计信息
- 总下载量: 14.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-13