定制 corrivate/tailwhen 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-18