corrivate/tailwhen
最新稳定版本:v0.2
Composer 安装命令:
composer require corrivate/tailwhen
包简介
helper function for conditional (tailwind) classes
README 文档
README
Inspired by Laravel Blade's @class directive. What if you could just use that in any PHP? With composer autoloading you can:
<span class="<?= tailwhen([ 'bg-red-800', // always 'text-white' => is_string('yes'), // condition is true, so style is applied 'font-bold' => is_numeric('no') // condition is false, so style is not applied ])?>">some text</span>
Results in:
<span class="bg-red-800 text-white">some text</span>
The tailwhen() function takes in an array of classes, optionally with conditionals. Classes without conditions like the bg-red-800 are always outputted. Classes with a condition are only outputted if the condition evaluates to true.
Setup
composer require corrivate/tailwhen
This installs the tailwhen() helper function and sets up autoload for it.
Corrivate
(en.wiktionary.org)
Etymology
From Latin corrivatus, past participle of corrivare ("to corrivate").
Verb
corrivate (third-person singular simple present corrivates, present participle corrivating, simple past and past participle corrivated)
(obsolete) To cause to flow together, as water drawn from several streams.
corrivate/tailwhen 适用场景与选型建议
corrivate/tailwhen 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.2k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 07 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 corrivate/tailwhen 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 corrivate/tailwhen 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-18