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.
统计信息
- 总下载量: 963
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-18