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!
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.
$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);
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 thesite/plugin
directory and rename it tokirbytextWrap
. -
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
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.
🤚 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!