PHP code example of hananils / kirby-attrs-helper

1. Go to this page and download the library: Download hananils/kirby-attrs-helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hananils / kirby-attrs-helper example snippets


<p
    <?= attrs([
        'id' => 'introduction',
        'class' => 'highlighted'
    ])

<p
    <?=attrs([
        'id' => $page->isHomePage() ? 'home' : false
    ])

<input
    <?=attrs([
        'type' => 'checkbox',
        'checked' => $page->isListed()
    ])

<article
    <?=attrs([
        'class' => [
            'published' => $page->published()->isTrue(),
            'has-image' => $page->images()->isNotEmpty()
        ]
    ])

<article
    <?=attrs([
        'class' => [
            'some', 'static', 'classnames',
            'published' => $page->published()->isTrue(),
            'has-image' => $page->images()->isNotEmpty()
        ]
    ])

<article
    <?=attrs([
        'data-list' => [
            'some', 'static', 'values'
        ]
    ], '|')