Skip to content

Helper for Kirby 3 to build attributes based on conditions, like conditionally adding classes to an element

License

Notifications You must be signed in to change notification settings

hananils/kirby-attrs-helper

Repository files navigation

Kirby Attributes helper

Attributes Helper is a plugin for Kirby 3 providing a helper method to build attributes based on conditions, like conditionally adding classes to an element.

Example

<h1
    <?=attrs([
        'id' => 'static-value',
        'class' => [
            'headline' => true // will always be added
            'is-active' => $page->active()->isTrue() // will only be added when the field value is true
        ]
    ])?>
>
    This is a headline with conditional class names.
</h1>

Installation

Download

Download and copy this repository to /site/plugins/attrs-helper.

Git submodule

git submodule add https://github.com/hananils/kirby-attrs-helper.git site/plugins/attrs-helper

Composer

composer require hananils/kirby-attrs-helper

License

This plugin is provided freely under the MIT license by hana+nils · Büro für Gestaltung.
We create visual designs for digital and analog media.

About

Helper for Kirby 3 to build attributes based on conditions, like conditionally adding classes to an element

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages