korcontrol/craft-classy
最新稳定版本:3.0.0-rc1
Composer 安装命令:
composer require korcontrol/craft-classy
包简介
Twig helpers inspired by https://github.com/JedWatson/classnames
README 文档
README
Twig helpers inspired by https://github.com/JedWatson/classnames
Usage
Filter
{% apply class(
"add-this-initially",
{
"add-this": true,
"remove-this": false,
"neither-add-nor-remove": null,
"add-or-remove": ifthis and ifthat,
"add-but-dont-remove": condition ? true : null,
"remove-but-dont-add": not condition ? false : null,
},
"add-this-regardless-of-above",
) %}
<mytag class="existing classes"> ... </mytag>
{% endapply %}
Function
<mytag class="{{ class("yup yes", { "maybe": ifthis and ifthat }) }}">
Which depending on the conditions ifthis and ifthat will give
<mytag class="yup yes maybe"> or <mytag class="yup yes">
Each argument can be either a string or a map.
A string argument will be treated as a class name (or multiple space-separated class names) to add.
An array argument is a map of class names to statuses.
Its keys are single class names or groups of space-seprated classes. The corresponding values can be
- strictly
trueto add the class or classes - strictly
falseto remove the class or classes nullor anything else to leave them alone
Any existing classes which aren't mentioned in any of these arguments are left alone.
Arguments are processed in order.
统计信息
- 总下载量: 7.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-23