newridetech/octobercms-classnames

Classnames plugin for October CMS

1.0.3 2018-09-28 02:05 UTC

This package is not auto-updated.

Last update: 2024-10-27 06:13:14 UTC


README

This plugin provides a developer tool to generate complex CSS classnames in Twig templates in a way that makes them more readable.

It's a port of https://github.com/JedWatson/classnames but for PHP.

If you want a pure PHP version without plugin, please try: https://github.com/newridetech/php-classnames

Instead of:

<nav class="link {{ item.isActive ? 'link--active' : '' }} {{ item.extra == 'primary' ? 'link--primary' : '' }}">
    ....
</nav>

Use:

<nav
    class="{{
        classnames('link', {
            'link--active': item.isActive,
            'link--primary': item.extra == 'primary'
        })
    }}"
>
    ....
</nav>

And that's all. :) I hope it helps.