yoanmalie/kirbytextwrap

Kirby plugin to get rid of the kirbytext() <p> enclosing tag, or replace them and add HTML attributes. It Keep the kirbytag working.

Installs: 18

Dependents: 0

Suggesters: 0

Security: 0

Stars: 8

Watchers: 2

Forks: 0

Type:kirby-plugin

1.2.0 2019-05-09 19:03 UTC

This package is auto-updated.

Last update: 2024-12-10 08:04:06 UTC


README

GitHub release License Kirby Version_2 Kirby Version_3

Kirby Plugin to remove or replace the <p> </p> enclosing tag and set HTML attributes. This will keep your kirbytag working.
Support both Kirby 2 and Kirby 3 version!

banner

How it works?

In your template, $page->title()->kirbytextWrap() will give you the same as kirbytext() without the <p> enclosing tag. This work also with the short ktw() alias.

Do much more

$page->title()->kirbytextWrap('h1') Will replace the <p> enclosing tag by <h1>.
$page->title()->kirbytextWrap('h1', ['class' => 'title']) Will replace the <p> enclosing tag by <h1> and add a class attribute with its value.

Put as many attributes as you want, you better create a variable for your array of attributes.

<?php
$attr = [
    'class' => 'dallas',
    'id' => 'larry',
    'aria-hidden' => 'true',
    'data-animation' => true,
];

echo $page->title()->kirbytextWrap('p', $attr);

Yeah cool but how to install?

You can install the kirbytextWrap plugin manually, with CLI, through Git submodule or with Composer.

  • Manually:
    Just download your desired version through the releases page, unzip and place the given folder into the site/plugin directory and rename it to kirbytextWrap.

  • Kirby CLI:

    kirby plugin:install yoanmalie/kirbytextwrap

    ⚠️ This will just work for Kirby 2 has CLI was removed on Kirby 3.

  • Git submodule:

    git submodule add https://github.com/yoanmalie/kirbytextwrap site/plugins/kirbytextWrap
    git submodule update --init --recursive
  • Composer:

    composer require yoanmalie/kirbytextwrap

Contributing

If you see a typo, or found a bug, please let me know! Share also your ideas through the issues tab.
Thanks for your help.

Clone this repo and run npm install.

git clone git@github.com:yoanmalie/kirbytextWrap.git
npm install

On each commit, Prettier will be run.

Credits

🤚 High five to @judbd who give me this plugin idea.
🎩 Hat tip to Jannik with his kirbytextRaw plugin who helped me when started to develop this plugin!