kirbytextWrap - Remove or replace enclosing p tag and more

I made my first Kirby Plugin! Let me introduce you KirbytextWrap().

Remove OR replace the <p> </p> enclosing tag on kirbytext() and add somes HTML attributes.

  • Work for both K2 and K3 version.
  • CLI and Composer support.
  • Keep yours kirbytag working.

$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.

Another example with more attributes:

$attr = [
    'class' => 'dallas',
    'id' => 'larry',
    'aria-hidden' => 'true',
    'data-animation' => true,

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

Feel free to report bug or suggestion.
Download and docs:

1 Like

Update v1.1.0!
It uses the new kirbytextinline() method available since Kirby 3.1.0 and still support the Kirby 2 and Kirby 3.0 versions :slight_smile: .

I’ve just updated a new version (1.2.0) who fix the Composer install.
As i didn’t noticed previously, the installation through Composer was failing… :sweat:

If you find something weird or something that just didn’t work, please let me know here or open an issue.