blue-tomato/template-engine-smarty
Composer 安装命令:
composer require blue-tomato/template-engine-smarty
包简介
ProcessWire module adding Smarty to the TemplateEngineFactory
README 文档
README
A ProcessWire module adding Smarty to the TemplateEngineFactory.
Requirements
- ProcessWire
3.0or newer - TemplateEngineFactory
2.0or newer - PHP
7.0or newer - Composer
The
1.xversion of this module is available on the 1.x branch. Use this version if you still use TemplateEngineFactory1.x.
Installation
Execute the following command in the root directory of your ProcessWire installation:
composer require blue-tomato/template-engine-smarty:^2.0
This will install the TemplateEngineSmarty and TemplateEngineFactory modules in one step. Afterwards, don't forget to enable Smarty as engine in the TemplateEngineFactory module's configuration.
ℹ️ This module includes test dependencies. If you are installing on production with
composer install, make sure to pass the--no-devflag to omit autoloading any unnecessary test dependencies!.
Configuration
The module offers the following configuration:
Template files suffixThe suffix of the Smarty template files, defaults totpl.Provide ProcessWire API variables in Smarty templatesAPI variables ($pages,$input,$config...) are accessible in Smarty, e.g.{{ config }}for the config API variable.DebugIf enabled, Smarty outputs debug information.Compile CheckIf enabled, templates are recompiled whenever the source code changes.Error ReportingIf set tofalse, Smarty will silently ignore invalid variables (variables and or attributes/methods that do not exist) and replace them with anullvalue. When set totrue, Smarty throws an exception insteadEscape HTMLIf enabled, templates will auto-escape variables. If you are using ProcessWire textformatters to escape field values, do not enable this feature.
Extending Smarty
It is possible to extend Smarty after it has been initialized by the module. Hook the method TemplateEngineSmarty::initSmarty
to register custom functions, extensions, global variables, filters etc.
Here is an example how you can use the provided hook to attach a custom function.
function foo_function($params, $smarty) { return 'bar'; }; wire()->addHookAfter('TemplateEngineSmarty::initSmarty', function (HookEvent $event) { /** @var \Smarty $smarty */ $smarty = $event->arguments('smarty'); $smarty->registerPlugin("function", "foo", "foo_function"); }); // ... and then use it anywhere in a Smarty template: {foo}
The above hook can be put in your
site/init.phpfile. If you prefer to use modules, put it into the module'sinit()method and make sure that the module is auto loaded.
blue-tomato/template-engine-smarty 适用场景与选型建议
blue-tomato/template-engine-smarty 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.79k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2019 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「smarty」 「processwire」 「smarty-engine」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 blue-tomato/template-engine-smarty 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 blue-tomato/template-engine-smarty 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 blue-tomato/template-engine-smarty 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Installs processwire 3rd party modules to PW system "site/modules" directory.
Rewritten Smarty foreach variant that was invented for use in xoops, but nowadays is used in some other PHP based CMS'es
Provides ProcessWire integration for various template engines such as Twig.
Modified Smarty for Rudrax
Modified Smarty for Rudrax
Module for ProcessWire which automatically generates Blurhashs.
统计信息
- 总下载量: 2.79k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-27